source: tools/ruby-script-encrypt @ 358

Revision 358, 974 bytes checked in by henning, 7 months ago (diff)

ruby-script-encrypt: another minor change in the comment

  • Property svn:executable set to *
Line 
1#!/usr/bin/env ruby
2# vi: set fileencoding=utf-8 :
3
4=begin
5        This script encrypts another one with 256 Bit AES, "swordfish" (the
6        marx one) as password and zero IV and outputs another script, which
7        decrypts the containing cipher and runs the code.
8        Disclaimer: This was written just for fun and may contain meaningless
9        use of cryptography. If you can not stand it, send complains to
10        henning on the honerable orgizm.net server.
11=end
12
13%w[base64 openssl].each {|r| require r}
14def a(m,k,t)
15        (a=OpenSSL::Cipher::Cipher.new('aes-256-cbc').send(m)).key=Digest::SHA256.digest(k)
16        #a.iv=File.open('/dev/random').read(32)
17        a.update(t)<<a.final
18end
19puts DATA.readlines,Base64.encode64(a :encrypt,:swordfish,File.new(ARGV[0]).readlines.join)
20__END__
21%w[base64 openssl].each {|r| require r}
22def a(m,k,t)
23        (a=OpenSSL::Cipher::Cipher.new('aes-256-cbc').send(m)).key=Digest::SHA256.digest(k)
24        a.update(t.unpack('m')[0])<<a.final
25end
26eval a :decrypt,:swordfish,DATA.readlines.to_s
27__END__
28end
29puts DATA.readlines,Base64.encode64(a :encrypt,:swordfish,File.new(ARGV[0]).readlines.join)
30__END__
31%w[base64 openssl].each {|r| require r}
32def a(m,k,t)
33        (a=OpenSSL::Cipher::Cipher.new('aes-256-cbc').send(m)).key=Digest::SHA256.digest(k)
34        a.update(t.unpack('m')[0])<<a.final
35end
36eval a :decrypt,:swordfish,DATA.readlines.to_s
37__END__
Note: See TracBrowser for help on using the repository browser.