jruby-pgp 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/org/sgonyea/pgp/Encryptor.java +14 -5
- data/lib/pgp.rb +6 -0
- data/lib/pgp/encryptor.rb +8 -8
- data/lib/pgp/version.rb +1 -1
- metadata +2 -2
@@ -66,8 +66,7 @@ public class Encryptor {
|
|
66
66
|
|
67
67
|
useBinaryFormat();
|
68
68
|
useZIPCompression();
|
69
|
-
|
70
|
-
_algorithm = PGPEncryptedData.CAST5;
|
69
|
+
useCAST5Algorithm();
|
71
70
|
}
|
72
71
|
|
73
72
|
public Encryptor() {
|
@@ -185,12 +184,19 @@ public class Encryptor {
|
|
185
184
|
return _algorithm;
|
186
185
|
}
|
187
186
|
|
188
|
-
/**
|
189
|
-
* @see org.bouncycastle.bcpg.SymmetricKeyAlgorithmTags
|
190
|
-
**/
|
191
187
|
public void setAlgorithm(int algorithm) {
|
192
188
|
_algorithm = algorithm;
|
193
189
|
}
|
190
|
+
public void useIDEAAlgorithm() { setAlgorithm(PGPEncryptedData.IDEA); }
|
191
|
+
public void useTripleDESAlgorithm() { setAlgorithm(PGPEncryptedData.TRIPLE_DES);}
|
192
|
+
public void useCAST5Algorithm() { setAlgorithm(PGPEncryptedData.CAST5); }
|
193
|
+
public void useBlowfishAlgorithm() { setAlgorithm(PGPEncryptedData.BLOWFISH); }
|
194
|
+
public void useSaferAlgorithm() { setAlgorithm(PGPEncryptedData.SAFER); }
|
195
|
+
public void useDESAlgorithm() { setAlgorithm(PGPEncryptedData.DES); }
|
196
|
+
public void useAES128Algorithm() { setAlgorithm(PGPEncryptedData.AES_128); }
|
197
|
+
public void useAES192Algorithm() { setAlgorithm(PGPEncryptedData.AES_192); }
|
198
|
+
public void useAES256Algorithm() { setAlgorithm(PGPEncryptedData.AES_256); }
|
199
|
+
public void useTwoFishAlgorithm() { setAlgorithm(PGPEncryptedData.TWOFISH); }
|
194
200
|
|
195
201
|
/** End Accessor Methods **/
|
196
202
|
|
@@ -227,6 +233,9 @@ public class Encryptor {
|
|
227
233
|
if (fileName == null)
|
228
234
|
fileName = PGPLiteralData.CONSOLE;
|
229
235
|
|
236
|
+
if (modificationTime == null)
|
237
|
+
modificationTime = new Date();
|
238
|
+
|
230
239
|
PGPEncryptedDataGenerator pgpDataGenerator = newPGPDataGenerator();
|
231
240
|
PGPLiteralDataGenerator dataGenerator = new PGPLiteralDataGenerator();
|
232
241
|
PGPCompressedDataGenerator compressedDataGenerator = new PGPCompressedDataGenerator(getCompression());
|
data/lib/pgp.rb
CHANGED
data/lib/pgp/encryptor.rb
CHANGED
@@ -17,24 +17,24 @@ module PGP
|
|
17
17
|
add_keys_from_enumerator(key_enumerator)
|
18
18
|
end
|
19
19
|
|
20
|
-
def encrypt(cleartext, filename=nil)
|
21
|
-
name
|
22
|
-
bytes
|
20
|
+
def encrypt(cleartext, filename=nil, mtime=nil)
|
21
|
+
name = filename.to_s if filename
|
22
|
+
bytes = cleartext.to_java_bytes
|
23
|
+
mtime ||= PGP.time_now
|
23
24
|
|
24
|
-
_encrypt(bytes, name)
|
25
|
+
_encrypt(bytes, name, mtime)
|
25
26
|
end
|
26
27
|
|
27
|
-
# @todo: Create an encryptStream method and pass it the file handle
|
28
28
|
def encrypt_file(file_path)
|
29
29
|
name = File.basename(file_path)
|
30
30
|
bytes = File.read(file_path).to_java_bytes
|
31
31
|
|
32
|
-
_encrypt(bytes, name)
|
32
|
+
_encrypt(bytes, name, File.mtime(file_path))
|
33
33
|
end
|
34
34
|
|
35
35
|
protected
|
36
|
-
def _encrypt(bytes, name)
|
37
|
-
encrypted_bytes = encrypt_bytes(bytes, name)
|
36
|
+
def _encrypt(bytes, name, modification_time=nil)
|
37
|
+
encrypted_bytes = encrypt_bytes(bytes, name, modification_time)
|
38
38
|
encrypted_string = String.from_java_bytes(encrypted_bytes)
|
39
39
|
end
|
40
40
|
|
data/lib/pgp/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: jruby-pgp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Scott Gonyea
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-11-
|
13
|
+
date: 2012-11-22 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|