Write RijndaelManaged in java/android« Back to Previous Page

Public Function encrpTxT(ByVal plaintext As String) As String

        Dim return_value As String = ""

        Try

            Dim original As String = plaintext

            ' Create a new instance of the RijndaelManaged

            ' class.  This generates a new key and initialization

            ' vector (IV).

            Using myRijndael As New RijndaelManaged()

                Dim key As String = "0123456789abcdef"

                Dim iv As String = "AAAAAAAAAAAAAAAA"

                Dim IVByte As Byte() = Encoding.ASCII.GetBytes(iv)

                Dim KEYByte As Byte() = Encoding.ASCII.GetBytes(key)

                ' Encrypt the string to an array of bytes.

                Dim encrypted As Byte() = EncryptStringToBytes(original, KEYByte, IVByte)

                'Display the original data and the decrypted data.

                return_value = Convert.ToBase64String(encrypted)

            End Using

        Catch ex As Exception

            return_value = ex.Message

        End Try

        Return return_value

    End Function

Public Function DecripTXT(ByVal cipherText As String) As String

        Dim return_value As String = ""

        Try

            Using myRijndael As New RijndaelManaged()

                Dim key As String = "0123456789abcdef"

                Dim iv As String = "AAAAAAAAAAAAAAAA"

                Dim IVByte As Byte() = Encoding.ASCII.GetBytes(iv)

                Dim KEYByte As Byte() = Encoding.ASCII.GetBytes(key)

                Dim encripted As String = cipherText

                ' Decrypt the bytes to a string.

                Dim roundtrip As String = DecryptStringFromBytes(encripted, KEYByte, IVByte)

                'Display the original data and the decrypted data.

                return_value = roundtrip

            End Using

        Catch ex As Exception

            return_value = ""

        End Try

        Return return_value

    End Function
This is VB code, I want the same code but in android/java platform. Do you have the same encryption/decryption code in android/java??
Posted by Nora (Questions:4, Answers:5)
Asked on July 23, 2013 1:50 pm
Category: Android
No account?



It's FREE!

Like what you have found?


... and keep us going