Changeset 363


Ignore:
Timestamp:
23.02.2010 17:07:18 (5 months ago)
Author:
henning
Message:

ruby-script-encrypt: fixed left bugs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/ruby-script-encrypt

    r362 r363  
    11#!/usr/bin/env ruby 
    22# vi: set fileencoding=utf-8 : 
    3  
    4 # XXX Broken if input file size >= 32 byte. Should be connected to AES 
    5 #     block size. Debug anyone? 
    6  
    73=begin 
    8         This script encrypts another one with 256 Bit AES, "swordfish" (the 
    9         marx one) as password and zero IV and outputs another script, which 
    10         decrypts the containing cipher and runs the code. 
    11         Disclaimer: This was written just for fun and may contain meaningless 
    12         use of cryptography. If you can not stand it, send complains to 
    13         henning on the honerable orgizm.net server. 
     4        This  script  encrypts  another  one  with  256 Bit AES, 
     5        "swordfish" (the marx one)  as password and  zero IV and 
     6        outputs another  script,  which decrypts the  containing 
     7        cipher and runs the code. 
     8        Disclaimer:     This was  written just  for fun  and may 
     9        contain meaningless use of cryptography.  If you can not 
     10        stand it,  send complains  to henning  on the  honerable 
     11        orgizm.net server. 
    1412=end 
    15  
    16 ARGV[0] ? nil:($stderr<<"#{$0} <script>\n";exit) 
    17 %w[base64 openssl].each{|r| require r} 
    18 def a(m,k,t) 
    19         (a=OpenSSL::Cipher::Cipher.new('aes-256-cbc').send(m)).key=Digest::SHA256.digest(k) 
    20         a.update(t)<<a.final 
    21 end 
    22 puts DATA.readlines,Base64.encode64(a :encrypt,:swordfish,File.new(ARGV[0]).readlines.join) 
     13ARGV[0] ? nil: ($stderr<<"#{$0} <script>\n";exit); %w[base64 
     14openssl].each{|r| require r};(a=OpenSSL::Cipher::Cipher.new( 
     15'aes-256-cbc').encrypt).key=Digest::SHA256.digest(:swordfish 
     16); puts DATA.readlines, Base64.encode64( a.update( File.new( 
     17ARGV[0]).readlines.join)<<a.final) 
    2318__END__ 
    2419#!/usr/bin/env ruby 
    25 %w[base64 openssl].each {|r| require r} 
    26 def a(m,k,t) 
    27         (a=OpenSSL::Cipher::Cipher.new('aes-256-cbc').send(m)).key=Digest::SHA256.digest(k) 
    28         a.update(t.unpack('m')[0])<<a.final 
    29 end 
    30 eval a :decrypt,:swordfish,DATA.readlines.to_s 
     20%w[base64 openssl].each{|r| require r}; (a=OpenSSL::Cipher:: 
     21Cipher.new('aes-256-cbc').decrypt).key= Digest::SHA2.digest( 
     22:swordfish); eval( a.update( Base64.decode64( DATA.readlines 
     23.join))<<a.final) 
    3124__END__ 
Note: See TracChangeset for help on using the changeset viewer.