

LONG CRYPTEXT HOW TO
These instructions show you how to make a 5-piece-cryptex of concrete size, if you want a different size and/or more or less pieces, just adjust the size. You can make your own cryptex and make use of things that would otherwise end up in your trashbin, such as toilet paper rolls or pieces of cardboard.
LONG CRYPTEXT CODE
The cryptex hides something inside and gives it away only when you turn the code correctly. If you read Dan Brown’s book The DaVinci Code or saw the movie, you know what a cryptex is. When you test the application, notice that it will not decrypt the data if you provide the wrong password.This year I deicded to make Lily a cryptex for her birthday. MsgBox("The data could not be decrypted with the password.")Īdd user interface code to call the TestEncoding and TestDecoding methods. MsgBox("The plain text is: " & plainText)Ĭatch ex As
LONG CRYPTEXT PASSWORD
' DecryptData throws if the wrong password is used.ĭim plainText As String = wrapper.DecryptData(cipherText) Sub TestDecoding()ĭim cipherText As String = My.( My. &Īdd a method that reads the encrypted string from the user's My Documents folder and decrypts the string with the wrapper's DecryptData method. MsgBox("The cipher text is: " & cipherText) Sub TestEncoding()ĭim plainText As String = InputBox("Enter the plain text:")ĭim password As String = InputBox("Enter the password:")ĭim cipherText As String = wrapper.EncryptData(plainText) In a separate class, add a method that uses the wrapper's EncryptData method to encrypt a string and write it to the user's My Documents folder. In this example, it is used to securely store private user data in a publicly accessible text file. The wrapper class can now be used to protect user assets. ' Convert the plaintext stream to a string. ' Create the decoder to write to the stream.ĭecStream.Write(encryptedBytes, 0, encryptedBytes.Length) ' Convert the encrypted text string to a byte array.ĭim encryptedBytes() As Byte = Convert.FromBase64String(encryptedtext) Return Convert.ToBase64String(ms.ToArray)Īdd a public method that decrypts a string. ' Convert the encrypted stream to a printable string. ' Use the crypto stream to write the byte array to the stream.ĮncStream.Write(plaintextBytes, 0, plaintextBytes.Length) ' Create the encoder to write to the stream. ' Convert the plaintext string to a byte array. TripleDes.IV = TruncateHash("", TripleDes.BlockSize \ 8)Īdd a public method that encrypts a string. TripleDes.Key = TruncateHash(key, TripleDes.KeySize \ 8) The key parameter controls the EncryptData and DecryptData methods. GetBytes(key)ĭim hash() As Byte = sha1.ComputeHash(keyBytes)Īdd a constructor to initialize the 3DES cryptographic service provider. Private Function TruncateHash(ĭim sha1 As New SHA1CryptoServiceProvider Private TripleDes As New TripleDESCryptoServiceProviderĪdd a private method that creates a byte array of a specified length from the hash of the specified key. In the Simple3Des class, add a private field to store the 3DES cryptographic service provider. Public NotInheritable Class Simple3DesĪdd an import of the cryptography namespace to the start of the file that contains the Simple3Des class. To create the encryption wrapperĬreate the Simple3Des class to encapsulate the encryption and decryption methods. For more information, see DES and Rijndael. The Rijndael (now referred to as Advanced Encryption Standard ) and Triple Data Encryption Standard (3DES) algorithms provide greater security than DES because they are more computationally intensive.
