我最近尝试使用中继方服务公钥加密Saml2断言.不幸的是,我甚至无法完成测试阶段
这是我的代码
public class EncryptionTest {
public static void main(String args[]){
try {
// The Assertion to be encrypted
FileInputStream fis;
DataInputStream in, in2;
File f = new File("src/main/resources/AssertionTest");
byte[] buffer = new byte[(int) f.length()];
in = new DataInputStream(new FileInputStream(f));
in.readFully(buffer);
in.close();
//Assertion = DataInputStream.readUTF(in);
String in_assert = new String(buffer);
System.out.println(in_assert);
org.apache.axiom.om.OMElement OMElementAssertion = org.apache.axiom.om.util.AXIOMUtil.stringToOM(in_assert);
Assertion assertion = convertOMElementToAssertion2(OMElementAssertion);
// Assume this contains a recipient's RSA public key
Credential keyEncryptionCredential;
keyEncryptionCredential = getCredentialFromFilePath("src/main/resources/cert.pem");
EncryptionParameters encParams = new EncryptionParameters();
encParams.setAlgorithm(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES128);
KeyEncryptionParameters …Run Code Online (Sandbox Code Playgroud) encryption public-key-encryption assertion opensaml saml-2.0
我有这个PHP函数(使用PHP 5.3),我用来解密文件,它曾经工作得很好,但现在我转移到Amazon EC2(基于Amazon Linux Image 2012.3),似乎mcrypt安装已损坏或根本不可用.
初步测试表明,文件解密可以在较小的文件上工作,但不能在20MB +文件上工作(不是特别大的文件).
我将问题跟踪到此行,这导致错误500(我没有得到mcrypt_module_open is undefined,只有500服务器错误)
$td = mcrypt_module_open ('rijndael-128', '', 'cbc', '');
Run Code Online (Sandbox Code Playgroud)
有点奇怪,我检查了/etc/php.ini,我根本看不到mcrypt(假设我正在查看正确的php.ini /路径!)
PHP代码/功能是:
function decrypt_file ($inputfile, $outputfile)
{
$key = FILE_KEY; // <-- assign private key
$buffersize = 16384;
// Open $inputfile for reading binary
$input = fopen ($inputfile, 'rb');
// Error opening $inputfile, return false
if (!$input)
return false;
// Open $outputfile for writing binary
$output = fopen ($outputfile, 'wb');
// Error opening …Run Code Online (Sandbox Code Playgroud) 我是加密/解密的新手.我正在尝试解密一个加密的输入字符串,并输出44个字符.
这是我到目前为止,但在尝试执行"TransformFinalBlock"函数时,我一直收到"错误的数据".
public static String Decrypt(String input)
{
try{
byte[] inputArray = Convert.FromBase64String(input);
TripleDESCryptoServiceProvider tripleDES = new TripleDESCryptoServiceProvider();
tripleDES.KeySize = 128;
tripleDES.Key = UTF8Encoding.UTF8.GetBytes("0123456789ABCDEF");
tripleDES.IV = UTF8Encoding.UTF8.GetBytes("ABCDEFGH");
tripleDES.Mode = CipherMode.ECB;
tripleDES.Padding = PaddingMode.PKCS7;
ICryptoTransform transform = tripleDES.CreateDecryptor();
byte[] resultArray = transform.TransformFinalBlock(inputArray, 0, inputArray.Length);
tripleDES.Clear();
return UTF8Encoding.UTF8.GetString(resultArray);
}
catch(Exception except){
Debug.WriteLine(except + "\n\n" + except.StackTrace);
return null;
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用使用受版权保护的pdf文件的ios应用程序.我正在寻找一些简单的方法来混淆文件的安全性,这不需要我通过额外的大众市场CCATS加密审查过程,但也将确保版权所有者我已经尽我所能保持他们的数据安全.我当然用密码保护文件,但我想进一步提高一两步.是否有一个简单的方法来XOR或以其他方式散列或混淆我将在我的服务器上托管的pdf文件,然后让ios设备下载它并使用objective-c代码将其恢复为常规密码保护的pdf文件,以便它可以节省它在文档目录中(我不担心它在设备上的安全性,就像它坐在服务器上一样).我假设对于任何文件类型都是一样的.
因此,为了澄清我正在我的桌面上寻找一个简单的XOR或Hash混淆/加密方法,它具有相应的目标c代码,ios设备可以在下载后快速解码我的文件并将其保存到文档目录.
非常感谢!
以下是关于CCATS限制的答案... 如果使用简单的XOR密码,需要申请CCATS吗?
如果加密函数需要密钥,那么如何对源中的密钥进行模糊处理以使反编译不会泄露密钥从而启用解密?
我正在阅读的这本书解释了算法如下:
交换发生如图所示

我把以下python代码放在一起,看看它是如何工作的......它没有.请帮我理解我缺少的东西:
#!/usr/bin/python
n=22 # publicly known
g=42 # publicly known
x=13 # only Alice knows this
y=53 # only Bob knows this
aliceSends = (g**x)%n
bobComputes = aliceSends**y
bobSends = (g**y)%n
aliceComputes = bobSends**x
print "Alice sends ", aliceSends
print "Bob computes ", bobComputes
print "Bob sends ", bobSends
print "Alice computes ", aliceComputes
print "In theory both should have ", (g**(x*y))%n
---
Alice sends 14
Bob computes 5556302616191343498765890791686005349041729624255239232159744
Bob sends 14
Alice computes 793714773254144
In …Run Code Online (Sandbox Code Playgroud) 使用https://raw.github.com/usefulfor/usefulfor/master/security/JBoss.java上的代码,我做了以下工作:
bash-3.2$ java -cp . JBoss -e testpython
-27038292d345798947e2852756afcf0a
bash-3.2$ java -cp . JBoss -d -27038292d345798947e2852756afcf0a
testpython
Run Code Online (Sandbox Code Playgroud)
但是,我不能为我的生活,弄清楚如何使用python中的pycrypto解密字符串'27038292d345798947e2852756afcf0a'.我的理解是Java代码使用的是Blowfish,而"jaas就是这种方式"作为密码的关键.但我无法理解如何在python中执行此操作.以下结果导致大多数不可打印的垃圾:
import Crypto
from Crypto.Cipher import Blowfish
from base64 import b64encode, b64decode
bs = Blowfish.block_size
key = 'jaas is the way'
plaintext = b'27038292d345798947e2852756afcf0a'
iv = '\0' * 8
c1 = Blowfish.new(key, Blowfish.MODE_ECB)
c2 = Blowfish.new(key, Blowfish.MODE_CBC, iv)
c3 = Blowfish.new(key, Blowfish.MODE_CFB, iv)
c4 = Blowfish.new(key, Blowfish.MODE_OFB, iv)
msg1 = c1.decrypt(plaintext)
msg2 = c2.decrypt(plaintext)
msg3 = c3.decrypt(plaintext)
msg4 = c4.decrypt(plaintext)
print …Run Code Online (Sandbox Code Playgroud) 我正在帮助构建具有多个自定义配置文件的ASP.NET C#应用程序.我们web.config使用<configSections><section /></configSections>确保设置的元素将这些元素存储在文件外部,restartOnExternalChanges="false"因此文件保存不会重新启动应用程序.
为了管理这些设置,我们构建了ASPX页面来读取,更新和保存各个部分和值.对于纯文本部分,这非常有效.管理员登录应用程序的配置部分,进行更改,保存并立即生效.
但是我们在其自己的外部文件中有一个部分,就像所有其他部分一样,也是加密的.无论何时保存该部分,IIS应用程序都会重新启动会话.这意味着登录管理员进行配置更改,并且所有登录到应用程序用户端的最终用户都必须再次登录,这令人沮丧.
有没有办法在保存加密配置节时避免IIS应用程序重启?
我们当前的加密配置部分处理代码如下所示:
public class CredentialsConfig : ConfigurationSection
{
Configuration Config = null;
CredentialsConfig Section = null;
public static CredentialsConfig GetConfig()
{
Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
CredentialsConfig section = config.GetSection("credentials") as CredentialsConfig;
// Ensure the current file is encrypted
if (!section.SectionInformation.IsProtected)
{
section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
section.SectionInformation.ForceSave = true;
config.Save();
}
return section;
}
public CredentialsConfig GetConfigForUpdate()
{
Config = WebConfigurationManager.OpenWebConfiguration("~");
Section = Config.GetSection("credentials") as CredentialsConfig;
return Section;
}
public void SaveConfig()
{ …Run Code Online (Sandbox Code Playgroud) 我在创建公钥/私钥对并使用它来加密文件时遇到了问题.
首先我生成私钥:
openssl genrsa -out private.pem 2048
Run Code Online (Sandbox Code Playgroud)
然后我提取公钥:
openssl rsa -in private.pem -out public.pem -outform PEM -pubout
Run Code Online (Sandbox Code Playgroud)
这样我就可以加密我的文件了:
openssl rsautl -encrypt -inkey public.pem -in myfile.txt -out file.ssl
Run Code Online (Sandbox Code Playgroud)
但后来我被告知:
Loading 'screen' into random state - done
unable to load Private Key
7064:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:696:
Expecting: ANY PRIVATE KEY
Run Code Online (Sandbox Code Playgroud)
我不明白......为什么要加载私钥?如何使用公钥加密文件?
我试图通过Ruby中的密码"DES-EDE3-CBC"加密数据,然后用Java解密加密数据.
这是Ruby中的代码我做加密:
require 'digest'
require 'openssl'
require 'base64'
ALG = "DES-EDE3-CBC"
key = "80f28a1ef4aa9df6ee2ee3210316b98f383eb344"
cipher = OpenSSL::Cipher::Cipher.new(ALG)
cipher.pkcs5_keyivgen(key, nil)
cipher.encrypt
data = "hello"
result = cipher.update(data)
result << cipher.final
# Write the data to file.
File.open("enc.txt", "wb"){|f| f.write result}
Run Code Online (Sandbox Code Playgroud)
然后用Java解密:
import java.security.*;
import java.*;
import java.io.*;
import javax.crypto.*;
import javax.crypto.spec.*;
public class Test{
public static void main(String[] args) throws Exception {
String key = "80f28a1ef4aa9df6ee2ee3210316b98f383eb344";
// Init the key
DESKeySpec desKeySpec = new DESKeySpec(key.getBytes());
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
Key secretKey …Run Code Online (Sandbox Code Playgroud) encryption ×10
c# ×2
cryptography ×2
java ×2
python ×2
asp.net ×1
assertion ×1
codeigniter ×1
decompiling ×1
encoding ×1
iis ×1
ios ×1
javax.crypto ×1
obfuscation ×1
objective-c ×1
opensaml ×1
openssl ×1
pdf ×1
php ×1
pycrypto ×1
rsa ×1
ruby ×1
saml-2.0 ×1
xcode ×1