I am developping an application by QML on nokia mobile phone which deal with a server.
I need to send an encrypted password "using DES encryption algorithm " to the server side.
how can I do this?
I have been used http://www.tero.co.uk/des/ as follow :
import "../js/Des.js" as Core
Button {
id:loginBtn
anchors.centerIn: parent
text: "test encryption"
onClicked: {
var doc = new XMLHttpRequest();
doc.onreadystatechange = function() {
if(doc.readyState == XMLHttpRequest.DONE) {
var a = doc.responseText;
print(a);
}
}
var result = Core.des ("My_key","1234");
print(result);
}
}
the result variable valus is : A????r4
can anyone tell me if i used that library wrong or tell me another solution .
Thanks in advance ..
Two solutions:
Do the DES encryption directly in QML using Javascript, a quick google gave this page http://www.tero.co.uk/des/
Or you create a small wrapper in C++ that you call from javascript to do the DES encryption. There are plenty of libraries available, for example http://delta.affinix.com/qca/
Related
am working on a project to develop a thesaurus app using flash as3. However my app works fine but it only displays the synonym for the word already being put inside the thesaurus API url. However, I want my app to allow any user input through the input text field. Is there a way to do that? Many thanks in advance. I use "Big Huge Thesaurus API" for synonyms. For example in below API URL only synonyms for word "mother" are displayed.
"http://words.bighugelabs.com/api/2/958af28ac9e3b21c650cbdd24a2466e8/mother/"
Here is my full code.
button1.addEventListener(MouseEvent.CLICK, loadScores);
function loadScores(e:MouseEvent):void {
var fileLoader:URLLoader = new URLLoader();
fileLoader.addEventListener(Event.COMPLETE, scoresLoadComplete);
fileLoader.load(new URLRequest("http://words.bighugelabs.com/api/2/958af28ac9e3b21c650cbdd24a2466e8/mother/"));
}
function scoresLoadComplete(evt:Event):void {
try {
var returnVars = evt.target.data;
highscores.htmlText = returnVars;
trace("Data retrieved successfully");
for (var myVars in returnVars) {
trace(myVars + ": " + returnVars[myVars]);
}
trace("***********************");
} catch (err:Error) {
trace("Can't parse loaded file: " + err.message);
}
}
Have an input text box in your application and set its instance name to "userinput" and change the following line in your code.
fileLoader.load(new URLRequest("http://words.bighugelabs.com/api/2/958af28ac9e3b21c650cbdd24a2466e8/mother/"));
to
fileLoader.load(new URLRequest("http://words.bighugelabs.com/api/2/958af28ac9e3b21c650cbdd24a2466e8/"+userinput.text+"/"));
I know this isn't google, but I wasn't able to find anything usefull and maybe you can give me some advice.
What I am looking for is some way to add an auto translation to strings in my react native application.
Right now I am using a workaround in which I translate some of the most common words manually - since that doesn't cover the whole language the outcome looks pretty unsatisfying :)
You could use react-native-i18n.
var I18n = require('react-native-i18n');
var Demo = React.createClass({
render: function() {
return (
<Text>{I18n.t('greeting')}</Text>
)
}
});
// Enable fallbacks if you want `en-US` and `en-GB` to fallback to `en`
I18n.fallbacks = true;
I18n.translations = {
en: {
greeting: 'Hi!'
},
fr: {
greeting: 'Bonjour!'
}
}
take user phone OS language using device info
https://www.npmjs.com/package/react-native-device-info#getdevicelocale
or using
I18n = require('react-native-i18n')
locale = I18n.currentLocale()
then Use power translator
https://www.npmjs.com/package/react-native-power-translator
//set your device language as a Target_Language on app start
TranslatorConfiguration.setConfig('Provider_Type', 'Your_API_Key','Target_Language', 'Source_Language');
//Fill with your own details
TranslatorConfiguration.setConfig(ProviderTypes.Google, 'xxxx','fr');
Use it as a component
<PowerTranslator text={'Engineering physics or engineering science refers to the study of the combined disciplines of physics'} />
add-on :
Use redux store or async storage to store all your string on first app start.
Then use translated text from store or storage.
IT will save your api bill as you have fixed strings.
sir for auto-translate. you can create one component where you can pass all strings (text) in your app, And use '#aws-sdk/client-translate' for translation, it's very fast and also works on dynamic data \
https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-translate/index.html
https://www.npmjs.com/package/#aws-sdk/client-translate
I need yout help to find out how to write and read files from external usb storage from Tizen Smart TVs. Problem starts when detecting it
`
/**
* Hello World Sample Project
*/
// import Label component
var Label = caph.require('ui.base.component.Label');
caph.app.addScene('main', $class({
$extends : caph.require('ui.base.Scene'),
// oncreate is called when the scene is created
oncreate : function() {
// add "Hello World"
this.addChild(new Label({
text : 'Hello World',
size : [ 500, 100 ],
position : [ 300, 400 ]
}).setTextSize('72px').setStyle({
backgroundColor : 'red',
color : 'white'
}));
/// Here the filesystem showd show me all the storages
tizen.filesystem.listStorages(checkCorruptedRemovableDrives);
}
})).run();
`
And here is the Success callback, this show me how much storages I have.
`
/* Success event handler */
var checkCorruptedRemovableDrives = function(storages) {
/// Here I will kow how much storages I have
console.log(storages.length);
for (var i = 0; i < storages.length; i++) {
if (storages[i].type != "EXTERNAL")
continue;
if (storages[i].state == "UNMOUNTABLE")
console.log("External drive " + storages[i].label + " is corrupted.");
}
};
`
Here is the method thrown when there are errors, this is never called.
var checkCorruptedRemovableDrivesError = function(storages){
console.log("Error");
}
Now, the console output is aways a simple 0 meanning I have no storage (but I have the internal one and two usb ones mounted).
Has Anyone faced this problem or have any Idea on how to solve it?
Samsung Tizen TV always uses "removable2" as label for USB.
So you don't need to use listStorage and getStorage.
Multiple USBs are distinguished as "removable2/sda1", "removable2/sda2"
tizen.filesystem.resolve("removable2", function(e){
e.listFiles(function(r){
for(i = 0; i < r.length; i++){
tizen.filesystem.resolve(r[i].path + r[i].name, function(t){
//You resolve USB root. Do something you want with USB.
}, function(t){
console.log("resolve error for " + r[i].path + r[i].name);
console.log(t);
}, "rw"); //you should use rw permission, to write something in usb.
}
});
},function(e){
console.log("removable2 resolve error");
console.log(e);
}, "r"); // permission should be given as r for removable2
Here is test app made by me. and you can check how to use SDK 1.5
http://www.samsungdforum.com/SamsungDForum/ForumView/3ad8bd6023af18a7?forumID=d88a711f47dc6e9f
This app is working in both of TV and SDK 1.5
Do you use Web Simulator?
APIs don't work in Web Simulator properly. It can't simulate things well.
When I check listStorage in 'emulator', it throws list of storages.
but even though I can get list of storage, I can't use it in filesystem. It is bug of SDK 1.4.
SDK 1.5 will have test features for USB storage, and it is planned to release in a month. Wait for a month :(
I looked at these links
http://www.tokbox.com/opentok/api/tools/js/documentation/overview/publish.html
http://www.tokbox.com/opentok/api/tools/js/tutorials/overview
but their are no examples for publishingunpublishing manually, that is, publishing/unpublishing without using 'streamCreated'/'streamDestroyed' event handler respectively.
The reason I want to do this is that I have a button to publish/unpublish so that the user can do it at will.
Is there a way to do this?
Yes and it is very simple. Check out the prepublish source code to see how. There are 2 functions, startPublishing() and stopPublishing() which achieve this.
Primarily they use session.publish(publisher);to publish and session.unpublish(publisher); to unpublish.
Here is code I have used to work off:
// Called by a button to start publishing to the session
function startPublishing() {
if (!publisher) {
var parentDiv = document.getElementById("myCamera");
var publisherDiv = document.createElement('div'); // Create a div for the publisher to replace
publisherDiv.setAttribute('id', 'opentok_publisher');
parentDiv.appendChild(publisherDiv);
var publisherProps = {
width : VIDEO_WIDTH,
height : VIDEO_HEIGHT
};
publisher = TB.initPublisher(apiKey, publisherDiv.id, publisherProps); // Pass the replacement div id and properties
session.publish(publisher);
show('unpublishLink');
hide('publishLink');
}
}
//Called by a button to stop publishing to the session
function stopPublishing() {
if (publisher) {
session.unpublish(publisher);
}
publisher = null;
show('publishLink');
hide('unpublishLink');
}
I have problems with this line,
OpenLayers.ProxyHost = "proxy.cgi?url=";
What should do other than writing above line in open layer code set?
My information
I try to get feature information of WMS image using WMSGetFeatureInfo command.I am using openlayer 2.10 ,geoserver and apache-tomcat-6.0.35.I can run tomcat using localhost:8080 and geoserver using localhost:8080/geoserver.
I am new to open layer and i see Frequently Asked Questions about the OpenLayers project but still can't figure out the answer.Yours any answers are very help full for me?
Thanks for your valuable time.
This link could be useful: Openlayers Proxy path usage
Some of the tasks that OpenLayers performs (including WFS requests) require the use of a proxy script because of restrictions in JavaScript on the use of XMLHTTPRequest making requests to remote servers.
Add that specific declaration before setting the map.
Start from here:
http://openlayers.org/dev/examples/2
Example of code:
/*
* Fix for OpenLayers using 900913 for web mercator and AGS using 102113 (it must run before map init)
OpenLayers.Layer.WMS.prototype.getFullRequestString = function(newParams,altUrl) {
try {
var projectionCode=typeof this.options.projection == 'undefined' ? this.map.getProjection() : this.options.projection;
} catch(err){
var projectionCode=this.map.getProjection();
}
this.params.SRS = projectionCode=="none" ? null : projectionCode;
return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply(this,arguments);
}
*/
OpenLayers.ProxyHost = proxyPath;
var options = {
projection: mercator, //EPSG:3785/900913
displayProjection: geographic, //EPSG:4326
theme: null,
maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),
maxResolution: 156543.0339,
units: 'm',
controls: [],
numZoomLevels: MAX_ZOOM_LEVEL,
allOverlays: true
};
OpenLayers.Util.DEFAULT_PRECISION = 18;
mp = new OpenLayers.Map('map', options);
addMaps();
addControls();
mp.addLayers([googlePhysical, googleSatellite, googleStreets, googleHybrid]);
//Enabling the preferred layers with a delay of 450 to be able to load the external backgrounds
setTimeout(setInitialLayersDiv, 450);
if (!mp.getCenter()) {
if (document.getElementById('userMapExtent').value != '') {
var sExtent = document.getElementById('userMapExtent').value.split(',');
mp.zoomToExtent(new OpenLayers.Bounds(sExtent[0], sExtent[1], sExtent[2], sExtent[3]), true);
} else {
mp.zoomToExtent(europeGoogleExtent);
}
}
J('#google_loading').hide('slow');