DECLARE @EmailEnc varbinary(maX)
declare @keyid uniqueidentifier
DECLARE @Email_test nvarchar(max)
set @Email_test = N'Sg@hotmail'
SELECT top 1 @keyid=[key_guid] FROM sys.symmetric_keys order by newid()
SET @EmailEnc=CAST(ENCRYPTBYKEY(@keyid,@Email_test) AS varbinary(max))
select @Email_test,@keyid,@EmailEnc
Run Code Online (Sandbox Code Playgroud)
结果
Sg@hotmail D790AE00-63FC-4BC5-8182-073BACDF1B12 NULL (1 行受影响) 为什么是 Null ?? 有任何想法吗??
有没有办法使用另一个字符串作为密钥在 VB.net 中加密/解密文本(字符串形式)?意思是,如果一个用户使用这个密钥加密,另一个用户需要使用相同的密钥解密?
我的意思不是公钥和私钥加密或任何类型的加密。
有人可以帮我为这些建造两个潜艇吗?
如果不是,那么在没有公钥/私钥的情况下加密/解密数据的第二好方法是什么?
我想做一个简单的方法来安全地发送消息。
谢谢您的帮助!
我想制作一个链接到社交引擎数据库的其他注册页面,但是当我对密码进行MD5并将其存储在se_users表中时,用户无法登录,我相信社交引擎有另一种加密方法,可以有人请给我一个功能来加密社交引擎方式的密码?
这是他们的功能,但我不知道如何在我的脚本中实现它:
function user_password_crypt($user_password)
{
global $setting;
if( !$this->user_exists )
{
$method = $setting['setting_password_method'];
$this->user_salt = randomcode($setting['setting_password_code_length']);
}
else
{
$method = $this->user_info['user_password_method'];
}
// For new methods
if( $method>0 )
{
if( !empty($this->user_salt) )
{
list($salt1, $salt2) = str_split($this->user_salt, ceil(strlen($this->user_salt) / 2));
$salty_password = $salt1.$user_password.$salt2;
}
else
{
$salty_password = $user_password;
}
}
$user_password_crypt = md5($salty_password);
return $user_password_crypt;
}
Run Code Online (Sandbox Code Playgroud)
谢谢
下面的代码行在一个for循环中,其中j增加ansString了一个ASCII字符串,如000\Qg$M!*P000\gQYA+ h000\M|$skd 000\Qo}plsd000\.
ansString[j] = ((char)(paramString[j] >> j % 8 ^ paramString[j]));
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚如何让XOR和所有其他操作员反向找到paramString.感谢任何帮助.
我希望能够转换ArrayList<String>存储从BufferedReader读取的文件内容的内容,然后将内容转换为byte [],以允许使用Java的Cipher类对其进行加密.
我尝试过使用.getBytes()但它没有工作,因为我认为我需要首先转换ArrayList,而我在弄清楚如何做到这一点时遇到了麻烦.
码:
// File variable
private static String file;
// From main()
file = args[2];
private static void sendData(SecretKey desedeKey, DataOutputStream dos) throws Exception {
ArrayList<String> fileString = new ArrayList<String>();
String line;
String userFile = file + ".txt";
BufferedReader in = new BufferedReader(new FileReader(userFile));
while ((line = in.readLine()) != null) {
fileString.add(line.getBytes()); //error here
}
Cipher cipher = Cipher.getInstance("DESede/ECB/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, desedeKey);
byte[] output = cipher.doFinal(fileString.getBytes("UTF-8")); //error here
dos.writeInt(output.length);
dos.write(output);
System.out.println("Encrypted Data: " + Arrays.toString(output)); …Run Code Online (Sandbox Code Playgroud) 我需要一些端口代码java到javascript它处理加密.在给定相同密钥的情况下,我无法根据现有代码重现相同的密文.
我怀疑我无法弄清楚正确的模式.附上代码段 -
public String encrypt(String message, String enc_key) throws Exception {
try {
initEncrypt(enc_key);
byte[] encstr = cipher.doFinal(message.getBytes());
return HexUtil.HextoString(encstr);
} catch (BadPaddingException nse) {
throw new Exception("Invalid input String");
}
}
public void initEncrypt(String key) throws Exception {
try {
skeySpec = new SecretKeySpec(HexUtil.HexfromString(key), "AES");
cipher = Cipher.getInstance("AES");
// cipher.
cipher.init(1, skeySpec);
System.out.println(cipher.getAlgorithm());
} catch (NoSuchAlgorithmException nsae) {
throw new Exception("Invalid Java Version");
} catch (NoSuchPaddingException nse) {
throw new Exception("Invalid Key");
}
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Google KeyManagementService在C#中加密文本。我无法解密KeyManagementServiceClient.Encrypt使用KeyManagementServiceClient.Decrypt方法生成的密码。解密给了我:
Grpc.Core.RpcException: Status(StatusCode=InvalidArgument, Detail="Decryption failed: the ciphertext is invalid.")
Run Code Online (Sandbox Code Playgroud)
我尝试使用google try this API链接获取密码,并且由google API生成的密码长度与C#结果不同。
例如:纯文字: text
来自C#的密码:
TaRQSJ2KXrdmJJT6MmlD8RrcxzPJEa1jwAXWJ1puXg6nbl80aBcSLQBqSYOONfXhpZx8SyxCdB6mqTgr8uLJoAjva+Q4kN/p0+9RL2Sp2mHq4wjmZQ==
Run Code Online (Sandbox Code Playgroud)
来自API的密码:
TaRQSJ2KXv9ntnS7IszL077KNPtGJnqF9pSNiWANsq8gD0whezUSKwBqSYOOKKMifiWrfPDnHL5xETHPPlms0ztjkqa5hjdtkHwpzByLzi68A40
Run Code Online (Sandbox Code Playgroud)
有没有人分阶段进行发行?
这是我的示例代码
Grpc.Core.RpcException: Status(StatusCode=InvalidArgument, Detail="Decryption failed: the ciphertext is invalid.")
Run Code Online (Sandbox Code Playgroud) 我有这些私钥已转换为单行等效项。
这些键很多。
因此,我决定花一些时间来编写要转换的脚本。
这并没有产生太多。
-----BEGIN RSA PRIVATE KEY----pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=pEdInVAbH4d0PH4= pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=pEdInVAbH4d0PH4= pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=pEdInVAbH4d0PH4= pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=pEdInVAbH4d0PH4= pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=pEdInVAbH4d0PH4= -----END RSA PRIVATE KEY-----
Run Code Online (Sandbox Code Playgroud)
我在用 echo ~/.ssh/id_rsa | tr " " "\n"
返回:
-----BEGIN
RSA
PRIVATE
KEY-----
pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=
pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=
pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=
pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=
pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=pEdInVAbH4d0PH4=
-----END
RSA
PRIVATE
KEY-----
Run Code Online (Sandbox Code Playgroud)
我一直在尝试找出将其恢复为正确格式的最佳方法。
我正在寻找一种加密数据库中用户电子邮件的方法。由于加密总是生成其他字符串,因此失败。所以我拿了sha1。
在AuthenticatesUsers中,我已将凭据方法更改为:
protected function credentials(Request $request)
{
return ['email' => sha1(strtolower($request->email)), 'password' => ($request->password)];
}
Run Code Online (Sandbox Code Playgroud)
这对于登录/注册非常有用。但是重置密码存在问题。
重置密码使用SendsPasswordResetEmails特性。
那里有这个凭证方法:
protected function credentials(Request $request)
{
return $request->only('email');
}
Run Code Online (Sandbox Code Playgroud)
这总是失败,因为它找不到用户(因为用户是用sha1电子邮件保存的)
如果我将其更改为 return ['email' => sha1(strtolower($request['email']))];
我收到错误消息,表明电子邮件不在正确的RFC标准中,无法发送电子邮件。问题是,我找不到真正的地方,laravel是使用此电子邮件为用户搜索的地方。无论如何,我根本不知道如何解决这个问题。
我想对电子邮件本身进行加密,因为在德国,有一项法律强迫我们存储加密的个人数据,例如电子邮件。
尝试使用RSA加密消息:我一直收到此错误,但是我不确定这意味着什么:
生成密钥的代码
generator = KeyPairGenerator.getInstance("RSA");
RSAKeyGenParameterSpec kpgSpec = new RSAKeyGenParameterSpec(2048, BigInteger.valueOf(17489));
generator.initialize(kpgSpec);
KeyPair keyPair = generator.generateKeyPair();
publicKey = (RSAPublicKey) keyPair.getPublic();
privateKey = (RSAPrivateKey) keyPair.getPrivate();
Run Code Online (Sandbox Code Playgroud)
编码消息的代码
RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(new BigInteger(publicKeyBytes), BigInteger.valueOf(17489));
Cipher cipher;
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
PublicKey currentKey = (RSAPublicKey) keyFactory.generatePublic(pubKeySpec);
cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.ENCRYPT_MODE, currentKey);
byte[] encryptedBytes = cipher.doFinal(data.getBytes());
encrypted = bytesToString(encryptedBytes);
Run Code Online (Sandbox Code Playgroud)
错误:
W/System.err: java.lang.IllegalArgumentException: RSA modulus has a small prime factor
W/System.err: at com.android.org.bouncycastle.crypto.params.RSAKeyParameters.validate(RSAKeyParameters.java:46)
at com.android.org.bouncycastle.crypto.params.RSAKeyParameters.<init>(RSAKeyParameters.java:28)
at com.android.org.bouncycastle.jcajce.provider.asymmetric.rsa.RSAUtil.generatePublicKeyParameter(RSAUtil.java:44)
at com.android.org.bouncycastle.jcajce.provider.asymmetric.rsa.CipherSpi.engineInit(CipherSpi.java:288)
at com.android.org.bouncycastle.jcajce.provider.asymmetric.rsa.CipherSpi.engineInit(CipherSpi.java:406)
Run Code Online (Sandbox Code Playgroud) encryption ×10
java ×4
rsa ×2
string ×2
arraylist ×1
byte ×1
cryptography ×1
javascript ×1
laravel ×1
laravel-5 ×1
md5 ×1
openssl ×1
php ×1
ssh ×1
vb.net ×1