我已经阅读了以下主题并且他们帮助了一点,但我正在寻找更多信息.
如何使用BlackBerry的初始化矢量参数编写AES/CBC/PKCS5Padding加密和解密
基本上,我正在做的是编写一个程序,它将加密通过TCP/IP发送的请求,然后由服务器程序解密.加密需要是AES,并且做了一些研究我发现我需要使用CBC和PKCS5Padding.所以基本上我需要一个秘密密钥和一个IV.
我正在开发的应用程序是用于手机,所以我想使用java安全包来减小尺寸.我已完成设计,但不确定IV和共享密钥的实现.
这是一些代码:
// My user name
byte[] loginId = "login".getBytes();
byte[] preSharedKey128 = "ACME-1234AC".getBytes();
byte[] preSharedKey192 = "ACME-1234ACME-1234A".getBytes();
// 256 bit key
byte[] preSharedKey256 = "ACME-1234ACME-1234ACME-1234".getBytes();
byte[] preSharedKey = preSharedKey256;
// Initialization Vector
// Required for CBC
byte[] iv ={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
IvParameterSpec ips = new IvParameterSpec(iv);
byte[] encodedKey = new byte[loginId.length + preSharedKey.length];
System.arraycopy(loginId, 0, encodedKey, 0, loginId.length);
System.arraycopy(preSharedKey, 0, encodedKey, loginId.length, preSharedKey.length);
// The SecretKeySpec provides a mechanism for application-specific generation
// of cryptography …Run Code Online (Sandbox Code Playgroud) 我的同事和我正在就密码安全进行拳头文明讨论.请帮助我们解决分歧.
我们其中一个人认为:
我们中的另一个人采取以下观点:
思考?评论?你是否曾在一个实施这种做法的组织工作过?
我创建了一个连接到sql 2005服务器的c#应用程序(不是asp网页).在我的源代码中,此sql-server的密码和用户标识是ConnectionString中的纯文本编码.
SqlConnection con = new SqlConnection();
con.ConnectionString =
"Data Source=server1;"+
"Initial Catalog=mydatabase;"+
"Integrated Security=no;"+
"User ID=admin;Password=mypassword;";
con.Open();
Run Code Online (Sandbox Code Playgroud)
有没有一种简单的方法来加密密码或整个连接字符串,反汇编我的工具的其他人无法看到密码?
谢谢
我刚开始实施加密技术,而且我还在学习基础知识.
我的开源代码库需要对称加密功能.该系统有三个组件:
看看各种JavaScript库,我遇到了SJCL,它有一个可爱的演示页面:http://bitwiseshiftleft.github.com/sjcl/demo/
从这一点来看,为了解密密文,客户需要知道的(除了使用的密码之外)是:
用密文保存所有这些数据是否相对安全?请记住,这是一个开源代码库,除非我要求用户记住它们,否则我无法合理地隐藏这些变量(是的,正确).
任何建议表示赞赏
encryption passwords password-protection encryption-symmetric
假设我有一些数据和密码,我想以这样的方式加密数据,即只能使用正确的密码恢复.
这在技术上如何工作(即如何实现)?我经常听到人们使用bithifting进行加密,但是你如何根据密码进行加密?基于密码的加密如何工作?
一个例子是Mac OS X FileVault
谢谢.
如果您提供示例代码,最好是C,Objective-C或伪代码.
我正在尝试读取使用openssl生成的RSA公钥,如下所示:
Private Key:
openssl genrsa -out mykey.pem 1024
Public Key afterwards:
openssl rsa -in mykey.pem -pubout > somewhere.pub
Run Code Online (Sandbox Code Playgroud)
然后我试着读:
FILE *keyfile = fopen("somewhere.pub", "r");
RSA *rsa_pub = PEM_read_RSAPublicKey(keyfile, NULL, NULL, NULL);
//rsa_pub == NULL!
Run Code Online (Sandbox Code Playgroud)
当我正在阅读私钥时,它可以工作
FILE *keyfile = fopen("mykey.pem", "r");
RSA *rsa_pri = PEM_read_RSAPrivateKey(keyfile, NULL, NULL, NULL);
//all good
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我已经读过openssl生成RSA公钥的X509密钥.但我甚至无法加载X509发布密钥.
谢谢
我已经好几天没试成功了.
StackOverflow中有很多类似的问题,甚至其中有两个与我的完全相同,但是没有答案和未解决:1)将PHP RSA PublicKey转换为Android PublicKey 2)Android:如何使用RSA密钥解密openssl加密文件?
我的场景:我有一些使用RSA加密的文本(未经我加密).我在res/raw文件夹中有一个"public.key"文件,其中包含解密所需的公钥(与用于加密消息的私钥相关的公钥),格式如下例所示:

我看到很多关于如何解密RSA文本的例子,如下所示:
public static byte[] decryptRSA( PublicKey key, byte[] text) throws Exception
{
byte[] dectyptedText = null;
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
cipher.init(Cipher.DECRYPT_MODE, key);
dectyptedText = cipher.doFinal(text);
return dectyptedText;
}
Run Code Online (Sandbox Code Playgroud)
但我的问题是,如何从文件中获取正确的PublicKey实例?没有这方面的例子.
如果我只是尝试:
InputStream is = getResources().openRawResource(R.raw.public);
DataInputStream dis = new DataInputStream(is);
byte [] keyBytes = new byte [(int) is.available()];
dis.readFully(keyBytes);
dis.close();
X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes);
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
return keyFactory.generatePublic(spec);
Run Code Online (Sandbox Code Playgroud)
我在返回句子中得到一个InvalidKeyException.我需要解码Hex或Base64吗?公钥文件的第一行和最后一行是不是有问题(带有"---- BEGIN PUBLIC KEY ----"等等)?
也许我们可以在StackOverflow中第一次正确地得到这个答案:-)
我是Spring框架中的新手,我使用Spring框架来管理我的数据库连接等等.Applicaiton从属性文件中读取我的数据库连接参数.我需要的是将我的连接密码存储在属性文件中作为加密.这是我的datasource xml文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>file:${DBConfigFile}</value>
</property>
</bean>
<bean id="myDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${jdbc.driverClassName}" />
<property name="jdbcUrl" value="${jdbc.url}" />
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="initialPoolSize"><value>3</value></property>
<property name="minPoolSize"><value>3</value></property>
<property name="maxPoolSize"><value>50</value></property>
<property name="idleConnectionTestPeriod"><value>200</value></property>
<property name="acquireIncrement"><value>1</value></property>
<property name="maxStatements"><value>0</value></property>
<property name="numHelperThreads"><value>3</value></property>
</bean>
</beans>
Run Code Online (Sandbox Code Playgroud)
我很想写加密到属性文件的密码,我想知道Spring是否可以自动解密它.是否可以配置.先感谢您.
哪个是GNU/Linux系统上/ etc/shadow上使用的加密方法?我想为个人目的编写一个使用相同API的小程序,但目前我不知道从哪里开始.
提前致谢
我的问题是如何加密字符串:
String AndroidId;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.download_movie_activity);
cancel = (Button)findViewById(R.id.img_cancle);
linear= (LinearLayout)findViewById(R.id.progress);
linear.setVisibility(View.GONE);
String encrypted = "MzIyNTE2" + "OTQNzM4NTQ=";
Log.e("Encrypt", encrypted);
WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo wInfo = wifiManager.getConnectionInfo();
AndroidId = wInfo.getMacAddress();
AndroidId=encrypted;
Run Code Online (Sandbox Code Playgroud)
U如何加密我存储MAC地址的AndroidId.
encryption ×10
passwords ×3
android ×2
c ×2
java ×2
rsa ×2
aes ×1
c# ×1
hash ×1
linux ×1
linux-mint ×1
openssl ×1
properties ×1
spring ×1
sql ×1