Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
OTP4U (One Time Pad For You) - Mixer.java

Mixer.java

Caricato da: Teutoburgo
Scarica il programma completo

  1. /*
  2.     OTP4U 0.8.2 - One Time Pad for you
  3.     Copyright (C) 2003 Pierre Blanc
  4.     Pierre Blanc: blanc_teutoburgo@yahoo.it
  5.     http://www.teutoburgo.tk
  6.     http://it.geocities.com/teutoburgo
  7.  
  8.     This program is free software; you can redistribute it and/or modify
  9.     it under the terms of the GNU General Public License as published by
  10.     the Free Software Foundation; either version 2 of the License, or
  11.     (at your option) any later version.
  12.  
  13.     This program is distributed in the hope that it will be useful,
  14.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.     GNU General Public License for more details.
  17.  
  18.     You should have received a copy of the GNU General Public License
  19.     along with this program; if not, write to the Free Software
  20.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  21.     or go to      http://www.gnu.org/copyleft/gpl.html
  22. */
  23.  
  24. package tk.teutoburgo.otp4u.crypt;
  25.  
  26. import java.io.IOException;
  27. public class Mixer {
  28. /**
  29.  * Mixer constructor comment.
  30.  */
  31. public Mixer() {
  32.         super();
  33. }
  34.     public byte[] mix(byte[] publicKey, byte[] ciphertext) {
  35.                 int pl=publicKey.length, cl=ciphertext.length, n=pl+cl;
  36.         byte[] mixed = new byte[n];
  37.  
  38.         for (int i = 0; i < pl ; i++) {
  39.           mixed[i]=publicKey[i];
  40.         }
  41.         for (int i = pl; i < n ; i++) {
  42.           mixed[i]=ciphertext[i-pl];
  43.         }
  44.  
  45.         return mixed;
  46.     }
  47.     public byte[] getPublicKey(byte[] mixed, int k4k0Len) {
  48.                 byte[] publicKey=new byte[k4k0Len*2];
  49.                 System.arraycopy(mixed,0,publicKey,0,k4k0Len*2);
  50.  
  51.         return publicKey;
  52.     }
  53.  
  54.     public byte[] getCiphertext(byte[] mixed, int k4k0Len) {
  55.                 int cLen=mixed.length-k4k0Len*2;
  56.                 byte[] ciphertext=new byte[cLen];
  57.                 System.arraycopy(mixed,k4k0Len*2,ciphertext,0,cLen);
  58.  
  59.         return ciphertext;
  60.     }
  61.  
  62. public static void main(String args[]){
  63. }
  64. }