{"id":43,"date":"2015-09-12T14:23:25","date_gmt":"2015-09-12T14:23:25","guid":{"rendered":"https:\/\/einhugur.com\/blog\/?page_id=43"},"modified":"2015-09-12T15:04:05","modified_gmt":"2015-09-12T15:04:05","slug":"frequently-asked-questions-encryption","status":"publish","type":"page","link":"https:\/\/einhugur.net\/blog\/index.php\/frequently-asked-questions\/frequently-asked-questions-encryption\/","title":{"rendered":"Frequently asked questions &#8211; Encryption"},"content":{"rendered":"<h5 class=\"question\">I cannot decrypt encrypted data which I saved to a file, what can be the problem ?<\/h5>\n<p style=\"padding-left: 30px;\"><span style=\"color: #403f3f;\">The most common reason for that is when users have attempted to save<\/span><br \/>\n<span style=\"color: #403f3f;\"> encrypted data into a text file. Saving encrypted data to a text file does\u00a0not work because encrypted data can contain any symbol, including\u00a0control symbols for text files such as Chr(13).<\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #403f3f;\">When saving encrypted data then it either has to be saved into a<\/span><br \/>\n<span style=\"color: #403f3f;\"> BinaryStream or if its supposed to go into a Text file or other text media<\/span><br \/>\n<span style=\"color: #403f3f;\"> then it has to be encoded to HEX format or Base64.<\/span><\/p>\n<h5><span style=\"color: #000000;\">I cannot decrypt data that was encrypted on other machine, what can be the problem ?<\/span><\/h5>\n<p style=\"padding-left: 30px;\"><span style=\"color: #403f3f;\">1. Verify that the problem is not because of saving the data into a Text based container. (See the above).<\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #403f3f;\">2. Encrypted data is by nature binary data, which means that you may never ever put a text encoding or attempt to do any text encoding conversion on it. Verify that your Application does not assume it is text by putting encoding on it.<\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #403f3f;\">3. Encryption keys are considdered to be binary data. This means that the Key &#8220;Hello World&#8221; may not be the same as the Key &#8220;Hello World&#8221;.\u00a0However if you have explicitly defined the encoding of both &#8220;Hello World&#8221; to the same then &#8220;Hello World&#8221; is the same key as &#8220;Hello World&#8221;.<\/span><\/p>\n<h5>When I encrypt text then European characters get lost when I decrypt it,<br \/>\nwhat am I doing wrong ?<\/h5>\n<p style=\"text-align: left; padding-left: 30px;\"><span style=\"color: #403f3f;\">Encryption is on binary level, it only takes raw bytes and encrypts them. <\/span><br \/>\n<span style=\"color: #403f3f;\">The info on what encoding your text was is not a part of the raw bytes. This means that you are responsible for saving and restoring the encoding if you are working with text where you want to preserve encodings.<\/span><\/p>\n<p style=\"text-align: left; padding-left: 30px;\"><span style=\"color: #403f3f;\">Here is how it should be done:<\/span><\/p>\n<p style=\"text-align: left; padding-left: 30px;\"><span style=\"color: #403f3f;\">(Encrypt)<\/span><br \/>\n<span style=\"color: #403f3f;\">1. Save the Encoding of the text that you are about to Encrypt.<\/span><br \/>\n<span style=\"color: #403f3f;\">2. Encrypt the text. (Remember once it is in encrypted form then you may never ever tamper with the encoding).<\/span><\/p>\n<p style=\"text-align: left; padding-left: 30px;\"><span style=\"color: #403f3f;\">(Decrypt)<\/span><br \/>\n<span style=\"color: #403f3f;\">1. Decrypt the data.<\/span><br \/>\n<span style=\"color: #403f3f;\">2. Restore the encoding by using DefineEncoding (*not ConvertEncoding)<\/span><\/p>\n<p style=\"text-align: left; padding-left: 30px;\"><span style=\"color: #403f3f;\">* DefineEncoding because you are not actually going to convert, the bytes are allready all correct it is just it does not know what encoding it is, so by using DefineEncoding then we promise that the bytes are actually what you say the are.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I cannot decrypt encrypted data which I saved to a file, what can be the problem ? The most common reason for that is when users have attempted to save encrypted data into a text file. Saving encrypted data to a text file does\u00a0not work because encrypted data can contain any symbol, including\u00a0control symbols for &hellip; <a href=\"https:\/\/einhugur.net\/blog\/index.php\/frequently-asked-questions\/frequently-asked-questions-encryption\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Frequently asked questions &#8211; Encryption<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":41,"menu_order":10,"comment_status":"closed","ping_status":"closed","template":"","meta":{"spay_email":""},"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/Pd75nk-H","jetpack-related-posts":[{"id":137,"url":"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/ir-infrared-obstacle-reflection-photoelectric-sensor\/","url_meta":{"origin":43,"position":0},"title":"IR Infrared Obstacle Reflection Photoelectric Sensor","date":"September 20, 2015","format":false,"excerpt":"In this example we are going to connect to infrared obstacle reflection photoelectric sensor motion detection sensor. I am not going to deny it, I find this sensor to be awful rubbish. Without reading the data you can hook it up and see it when the 2nd green lights goes\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/09\/IRSensor-e1442754741492-225x300.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":128,"url":"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/dht11-and-dht22-humidity-temperature-sensors-3-pin-version\/","url_meta":{"origin":43,"position":1},"title":"DHT11 and DHT22 humidity & temperature sensors (3 pin version)","date":"September 20, 2015","format":false,"excerpt":"In this example we are going to connect\u00a0to DHT11 and or DHT22 humidity & temperature sensor. This sensor reads both the humidity and temperature. (This guide was updated on 24. Oct 2015, greatly improving the DHT11 device driver code and added DHT22 device driver code and wiring pictures for the\u2026","rel":"","context":"Similar post","img":{"alt_text":"DHT22 sensor","src":"https:\/\/i0.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/09\/DHT22.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":840,"url":"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/rdm6300-125khz-rfid-reader\/","url_meta":{"origin":43,"position":2},"title":"RDM6300 125Khz RFID reader","date":"April 13, 2017","format":false,"excerpt":"In this example we are going to connect to RDM6300 RFID reader. The RDM6300\u00a0is for 125 kHz RF tags. This board uses UART (serial communication) but the protocol is fairly simple to deal with. The RDM6300 seen from back and front And the antenna that comes with it. Disclaimer: We\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"https:\/\/i1.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2017\/04\/RFID125MainBoard.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":731,"url":"https:\/\/einhugur.net\/blog\/index.php\/basic-electronics\/led-orientation\/","url_meta":{"origin":43,"position":3},"title":"LED orientation","date":"July 17, 2016","format":false,"excerpt":"Orientation of a LED is important since a LED will not work if its oriented wrong. \u00a0 If we first look at normal LED in the picture bellow then you can see that you have two ways to identify the + and \u2013 or anode vs cathode. Its the length\u2026","rel":"","context":"Similar post","img":{"alt_text":"cathodemarkersimage","src":"https:\/\/i0.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2016\/07\/CathodeMarkersImage-1.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":55,"url":"https:\/\/einhugur.net\/blog\/index.php\/frequently-asked-questions\/frequently-asked-questions-installation\/","url_meta":{"origin":43,"position":4},"title":"Frequently asked questions - Installation","date":"September 12, 2015","format":false,"excerpt":"After installing plugins I get errors what can I do? We have had some cases where users have put directories into the Plugins directory. Do not put directories into the Plugins directory. The Plugins directory should only contain .xojo_plugin files in flat structure and nothing else. Where do I install\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":108,"url":"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/f85-vibration-sensor\/","url_meta":{"origin":43,"position":5},"title":"F85 Vibration sensor","date":"September 19, 2015","format":false,"excerpt":"In this example we are going to connect to\u00a0vibration sensor. This example is super easy after doing the infrared motion detection with the HC-SR501 in a previous example, since basically same code will work. I found this sensor to be excellent, it gives readings when I expect it to and\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"https:\/\/i1.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/09\/Sensor-connection-e1442664059628-225x300.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/pages\/43"}],"collection":[{"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=43"}],"version-history":[{"count":3,"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/pages\/43\/revisions"}],"predecessor-version":[{"id":47,"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/pages\/43\/revisions\/47"}],"up":[{"embeddable":true,"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/pages\/41"}],"wp:attachment":[{"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=43"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}