简体   繁体   English

C#加密Android解密

[英]C# Encryption Android Decryption

I encrypt a string in c# (RijndaelManaged), which returns a byte array. 我在c#(RijndaelManaged)中加密一个字符串,该字符串返回一个字节数组。

I want to save that byte array to a database in order to get it decrypted later in the android device. 我想将该字节数组保存到数据库,以便稍后在Android设备中对其进行解密。

I have tried converting it to base64 in c#, But as I understand android doesnt support base64 decoding before API8. 我曾尝试在c#中将其转换为base64,但据我了解,android在API8之前不支持base64解码。

Is there another way saving the byte array in the DB, so I can later fetch it and decrypt it on android? 还有另一种将字节数组保存在数据库中的方法,以便以后可以将其获取并在android上解密吗?

10X 10倍

Update : 更新:

you can implement the base64 encoding yourself on both sides so that you can be sure, you can see example code of how to implement Base64 encoding and decoding in languages like c, C++, java, and javascript on wikibooks 你可以实现的base64两侧编码自己,这样你可以肯定,你可以看到如何实现语言,如C Base64编码和解码示例代码,C ++,Java和JavaScript的维基教科书

Yes, if you are using SQL Server, you can use VarBinary 是的,如果您使用的是SQL Server,则可以使用VarBinary

you can read more about insert a byte array into database in this SO question 您可以在此问题中阅读有关在数据库中插入字节数组的更多信息

You can insert BLOB Data in SQLITE and MySql too 您也可以在SQLITEMySql中插入BLOB数据

You can find Java Base64 decoders everywhere http://www.source-code.biz/base64coder/java/ , add it to your Android project and you're off. 您可以在http://www.source-code.biz/base64coder/java/随处找到Java Base64解码器,并将其添加到您的Android项目中,然后退出。

If not, just translate each byte into two hexadecimal digits in C#, and then back in Android. 如果没有,只需在C#中将每个字节转换为两个十六进制数字,然后在Android中返回即可。 It's very easy to do so yourself. 自己这样做很容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM