Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #38361

Cipher.getInstance causing exception saying "length=4 index=7"

Newsgroups comp.lang.java.programmer
Date 2018-06-12 04:38 -0700
Message-ID <20305580-c3c7-4309-83ba-e3cbe594ec21@googlegroups.com> (permalink)
Subject Cipher.getInstance causing exception saying "length=4 index=7"
From tedpottel5@gmail.com

Show all headers | View raw


I have a small test program to try and encrypt the message hello world.  It keeps causing a exception when it calls getinstance.  code

       void test()     
            {
            try{    
            Cipher desCipher;
            byte[] internalKey={23,55,34,66,33,77};
            String str=("hellow world");
            myDesKey = new SecretKeySpec(internalKey, 0,4,"DES");
            desCipher = Cipher.getInstance("DES");

            // exception goes off here
            desCipher.init(Cipher.ENCRYPT_MODE, myDesKey);
          
  byte[] text = str.getBytes("UTF8");
            byte[] textEncrypted = desCipher.doFinal(text);

        } catch(Exception e)
        {
           
            String m=e.getMessage();
            return false;
        }
        return true;
    }

Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Cipher.getInstance causing exception saying "length=4 index=7" tedpottel5@gmail.com - 2018-06-12 04:38 -0700
  Re: Cipher.getInstance causing exception saying "length=4 index=7" Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-06-12 08:57 -0400
    Re: Cipher.getInstance causing exception saying "length=4 index=7" Eric Douglas <e.d.programmer@gmail.com> - 2018-06-12 07:36 -0700
      Re: Cipher.getInstance causing exception saying "length=4 index=7" Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-06-12 11:57 -0400
        Re: Cipher.getInstance causing exception saying "length=4 index=7" v_borchert@despammed.com (Volker Borchert) - 2018-06-12 19:32 +0000
  Re: Cipher.getInstance causing exception saying "length=4 index=7" Eric Douglas <e.d.programmer@gmail.com> - 2018-06-12 07:41 -0700
    Re: Cipher.getInstance causing exception saying "length=4 index=7" Eric Douglas <e.d.programmer@gmail.com> - 2018-06-12 08:33 -0700

csiph-web