Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > (Encryption Package) error: cannot find symbol symbol: class BaseNCode

Reply
Thread Tools

(Encryption Package) error: cannot find symbol symbol: class BaseNCode

 
 
clusardi2k@aol.com
Guest
Posts: n/a
 
      08-29-2012
When I include the below package (link 1) in a project, I get the following error message:

C:\...\src\org\apache\commons\codec\binary\Base64. java:50: error: cannot find symbol
public class Base64 extends BaseNCodec {
symbol: class BaseNCode

The code in (1) came from (2). I'd like to use both of these.

What am I doing wrong here! What should I be doing. (Do I need a dot jar for this.)

How do I encrypt strings. Also, do you have a simple example project.

Is there a better alternative to this package for encryption. What should I be considering

Many Thanks,

(Link 1)http://svn.apache.org/viewvc/commons...va?view=markup

(Link 2) http://zenu.wordpress.com/2011/09/21...compatibility/

FYI: Below is the complete output of the build:

C:\...\src\org\apache\commons\codec\binary\Base64. java:50: error: cannot find symbol
public class Base64 extends BaseNCodec {
symbol: class BaseNCodec
C:\...\src\org\apache\commons\codec\binary\Base64. java:321: error: cannot find symbol
void encode(byte[] in, int inPos, int inAvail, Context context) {
symbol: class Context
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:411: error: cannot find symbol
void decode(byte[] in, int inPos, int inAvail, Context context) {
symbol: class Context
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:188: error: cannot find symbol
this(MIME_CHUNK_SIZE, CHUNK_SEPARATOR, urlSafe);
symbol: variable MIME_CHUNK_SIZE
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:271: error: cannot find symbol
if (containsAlphabetOrPad(lineSeparator)) {
symbol: method containsAlphabetOrPad(byte[])
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:272: error: cannot find symbol
String sep = StringUtils.newStringUtf8(lineSeparator);
symbol: variable StringUtils
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:329: error: cannot find symbol
if (0 == context.modulus && lineLength == 0) {
symbol: variable lineLength
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:340: error: cannot find symbol
context.buffer[context.pos++] = PAD;
symbol: variable PAD
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:341: error: cannot find symbol
context.buffer[context.pos++] = PAD;
symbol: variable PAD
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:351: error: cannot find symbol
context.buffer[context.pos++] = PAD;
symbol: variable PAD
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:357: error: cannot find symbol
if (lineLength > 0 && context.currentLinePos > 0) {
symbol: variable lineLength
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:376: error: cannot find symbol
if (lineLength > 0 && lineLength <= context.currentLinePos) {
symbol: variable lineLength
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:376: error: cannot find symbol
if (lineLength > 0 && lineLength <= context.currentLinePos) {
symbol: variable lineLength
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:320: error: method does not override or implement a method from a supertype
@Override
C:\...\src\org\apache\commons\codec\binary\Base64. java:421: error: cannot find symbol
if (b == PAD) {
symbol: variable PAD
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:432: error: cannot find symbol
context.buffer[context.pos++] = (byte) ((context.ibitWorkArea >> 16) & MASK_8BITS);
symbol: variable MASK_8BITS
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:433: error: cannot find symbol
context.buffer[context.pos++] = (byte) ((context.ibitWorkArea >> & MASK_8BITS);
symbol: variable MASK_8BITS
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:434: error: cannot find symbol
context.buffer[context.pos++] = (byte) (context.ibitWorkArea & MASK_8BITS);
symbol: variable MASK_8BITS
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:454: error: illegal start of type
context.buffer[context.pos++] = (byte) ((context.ibitWorkArea) & MASK_8BITS);
C:\...\src\org\apache\commons\codec\binary\Base64. java:454: error: cannot find symbol
context.buffer[context.pos++] = (byte) ((context.ibitWorkArea) & MASK_8BITS);
symbol: variable MASK_8BITS
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:458: error: cannot find symbol
context.buffer[context.pos++] = (byte) ((context.ibitWorkArea >> & MASK_8BITS);
symbol: variable MASK_8BITS
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:459: error: illegal start of type
context.buffer[context.pos++] = (byte) ((context.ibitWorkArea) & MASK_8BITS);
C:\...\src\org\apache\commons\codec\binary\Base64. java:459: error: cannot find symbol
context.buffer[context.pos++] = (byte) ((context.ibitWorkArea) & MASK_8BITS);
symbol: variable MASK_8BITS
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:410: error: method does not override or implement a method from a supertype
@Override
C:\...\src\org\apache\commons\codec\binary\Base64. java:489: error: cannot find symbol
return octet == PAD_DEFAULT || (octet >= 0 && octet < DECODE_TABLE.length && DECODE_TABLE[octet] != -1);
symbol: variable PAD_DEFAULT
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:503: error: cannot find symbol
return isBase64(StringUtils.getBytesUtf8(base64));
symbol: variable StringUtils
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:518: error: cannot find symbol
if (!isBase64(arrayOctet[i]) && !isWhiteSpace(arrayOctet[i])) {
symbol: method isWhiteSpace(byte)
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:548: error: cannot find symbol
return StringUtils.newStringUtf8(encodeBase64(binaryData, false));
symbol: variable StringUtils
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:574: error: cannot find symbol
return StringUtils.newStringUtf8(encodeBase64(binaryData, false, true));
symbol: variable StringUtils
location: class Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:645: error: cannot find symbol
long len = b64.getEncodedLength(binaryData);
symbol: method getEncodedLength(byte[])
location: variable b64 of type Base64
C:\...\src\org\apache\commons\codec\binary\Base64. java:653: error: method encode in class Base64 cannot be applied to given types;
return b64.encode(binaryData);
required: byte[],int,int,Context
found: byte[]
reason: actual and formal argument lists differ in length
C:\...\src\org\apache\commons\codec\binary\Base64. java:665: error: method decode in class Base64 cannot be applied to given types;
return new Base64().decode(base64String);
required: byte[],int,int,Context
found: String
reason: actual and formal argument lists differ in length
C:\...\src\org\apache\commons\codec\binary\Base64. java:676: error: method decode in class Base64 cannot be applied to given types;
return new Base64().decode(base64Data);
required: byte[],int,int,Context
found: byte[]
reason: actual and formal argument lists differ in length
C:\...\src\org\apache\commons\codec\binary\Base64. java:749: error: method does not override or implement a method from a supertype
@Override
Note: C:\...\src\...\Login_Screen.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
34 errors
C:\...\nbproject\build-impl.xml:606: The following error occurred while executing this line:
C:\...\nbproject\build-impl.xml:247: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 5 seconds)
 
Reply With Quote
 
 
 
 
clusardi2k@aol.com
Guest
Posts: n/a
 
      08-29-2012
When I add the below code (from line 2 in first post), I see the error for constant "Base64.DEFAULT" as:
cannot find symbol
symbol: variable DEFAULT
//Code from link 2 in first posting:
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.binary.Base64;


private final String characterEncoding = "UTF-8";

private final String cipherTransformation = "AES/CBC/PKCS5Padding";

private final String aesEncryptionAlgorithm = "AES";

public byte[] decrypt(byte[] cipherText, byte[] key, byte [] initialVector) throws NoSuchAlgorithmException,
NoSuchPaddingException,
InvalidKeyException,
InvalidAlgorithmParameterException,
IllegalBlockSizeException,
BadPaddingException
{
Cipher cipher = Cipher.getInstance(cipherTransformation);

SecretKeySpec secretKeySpecy = new SecretKeySpec(key, aesEncryptionAlgorithm);

IvParameterSpec ivParameterSpec = new IvParameterSpec(initialVector);

cipher.init(Cipher.DECRYPT_MODE, secretKeySpecy, ivParameterSpec);

cipherText = cipher.doFinal(cipherText);

return cipherText;

}

public byte[] encrypt(byte[] plainText, byte[] key, byte [] initialVector) throws NoSuchAlgorithmException,
NoSuchPaddingException,
InvalidKeyException,
InvalidAlgorithmParameterException,
IllegalBlockSizeException,
BadPaddingException
{
Cipher cipher = Cipher.getInstance(cipherTransformation);

SecretKeySpec secretKeySpec = new SecretKeySpec(key, aesEncryptionAlgorithm);

IvParameterSpec ivParameterSpec = new IvParameterSpec(initialVector);

cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivParameterSpec);

plainText = cipher.doFinal(plainText);

return plainText;
}

private byte[] getKeyBytes(String key) throws UnsupportedEncodingException
{
byte[] keyBytes= new byte[16];

byte[] parameterKeyBytes= key.getBytes(characterEncoding);

System.arraycopy(parameterKeyBytes, 0, keyBytes, 0, Math.min(parameterKeyBytes.length, keyBytes.length));

return keyBytes;
}

/// <summary>
/// Encrypts plaintext using AES 128bit key and a Chain Block Cipher and returns a base64 encoded string
/// </summary>
/// <param name="plainText">Plain text to encrypt</param>
/// <param name="key">Secret key</param>
/// <returns>Base64 encoded string</returns>

public String encrypt(String plainText, String key) throws UnsupportedEncodingException,
InvalidKeyException,
NoSuchAlgorithmException,
NoSuchPaddingException,
InvalidAlgorithmParameterException,
IllegalBlockSizeException, BadPaddingException
{
byte[] plainTextbytes = plainText.getBytes(characterEncoding);

byte[] keyBytes = getKeyBytes(key);

return Base64.encodeToString(encrypt(plainTextbytes,keyBy tes, keyBytes), Base64.DEFAULT);

}

/// <summary>
/// Decrypts a base64 encoded string using the given key (AES 128bit key and a Chain Block Cipher)
/// </summary>
/// <param name="encryptedText">Base64 Encoded String</param>
/// <param name="key">Secret Key</param>
/// <returns>Decrypted String</returns>
public String decrypt(String encryptedText, String key) throws KeyException,
GeneralSecurityException,
GeneralSecurityException,
InvalidAlgorithmParameterException,
IllegalBlockSizeException,
BadPaddingException,
IOException
{
byte[] cipheredBytes = Base64.decode(encryptedText, Base64.DEFAULT);

byte[] keyBytes = getKeyBytes(key);

return new String(decrypt(cipheredBytes, keyBytes, keyBytes), characterEncoding);
}
 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      08-29-2012
(unknown) wrote:
> When I include the below package (link 1) in a project, I get the following error message:
>
> C:\...\src\org\apache\commons\codec\binary\Base64. java:50: error: cannot find symbol
> public class Base64 extends BaseNCodec {
>
> symbol: class BaseNCode
>
> The code in (1) came from (2). I'd like to use both of these.
>
> What am I doing wrong here! What should I be doing. (Do I need a dot jar for this.)


You apparently brought in part, not all, of the source code for the library you want to
use. This is not conventional or optimal.

Instead, either download or build the JAR, ensuring thus that it contains *all* the
project (Commons Codec in this case). Since Apache Commons is, well, common,
unless you're contributing to the project download the JAR rather than build it.

See the Java documentation for how to include JARs in the classpath with the
"-classpath" ("-cp" for short) argument to the Java tools.

> How do I encrypt strings. Also, do you have a simple example project.


http://lmgtfy.com/?q=Java+how+to+encrypt+strings

Note: Interrogative sentences should end in a question mark ("?").

> Is there a better alternative to this package for encryption. What should I be considering


What does "better" mean to you?

Apache Commons Codec is not an encryption library, so presumably any
encryption library would be better.

As for your other errors, the messages seem clear enough.

[snip]
> Note: C:\...\src\...\Login_Screen.java uses unchecked or unsafe operations.
> Note: Recompile with -Xlint:unchecked for details.


Don't use raw types.

Use generics correctly.

--
Lew
 
Reply With Quote
 
clusardi2k@aol.com
Guest
Posts: n/a
 
      08-29-2012
> On Wednesday, August 29, 2012 2:10:46 PM UTC-4, Lew wrote:
> Instead, either download or build the JAR, ensuring thus that it contains *all*
> the project (Commons Codec in this case). Since Apache Commons is, well,
> common, unless you're contributing to the project download the JAR rather than > build it.


Where can I get either the pre-built jar or *all* of the project!

Thank you,


 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      08-29-2012
(unknown) wrote:
> Lew wrote:
>> Instead, either download or build the JAR, ensuring thus that it contains *all*
>> the project (Commons Codec in this case). Since Apache Commons is, well,
>> common, unless you're contributing to the project download the JAR rather than > build it.

>
> Where can I get either the pre-built jar or *all* of the project!


http://lmgtfy.com/?q=Apache+Commons+Codec+downloads

--
Lew
 
Reply With Quote
 
clusardi2k@aol.com
Guest
Posts: n/a
 
      08-29-2012
> On Wednesday, August 29, 2012 2:31:26 PM UTC-4, Lew wrote:
> (unknown) wrote: > Lew wrote: >> Instead, either download or build the JAR,
> ensuring thus that it contains *all* >> the project (Commons Codec in this
> case). Since Apache Commons is, well, >> common, unless you're contributing
> to the project download the JAR rather than > build it. > > Where can I get
> either the pre-built jar or *all* of the project! http://lmgtfy.com/?

q=Apache+Commons+Codec+downloads -- Lew

When I add the java package and your dot jar (from http://commons.apache.org/codec/download_codec.cgi) to a project (as a library) and try to build it, I get error messages such as the below hard (if not impossible) to removeerror messages. The error messages are from the new package.

Compiling 46 source files to C:\...\build\classes
C:\...\src\org\apache\commons\codec\binary\Base64. java:324: error: cannot find symbol
if (context.eof) {
symbol: variable eof
location: variable context of type Context
C:\...\src\org\apache\commons\codec\binary\Base64. java:330: error: cannot find symbol
context.eof = true;
symbol: variable eof
location: variable context of type Context
C:\...\src\org\apache\commons\codec\binary\Base64. java:331: error: cannot find symbol
if (0 == context.modulus && lineLength == 0) {
symbol: variable modulus
location: variable context of type Context
C:\...\src\org\apache\commons\codec\binary\Base64. java:334: error: method ensureBufferSize in class BaseNCodec cannot be applied to given types;
ensureBufferSize(encodeSize, context);
required: int
found: int,Context
reason: actual and formal argument lists differ in length
C:\...\src\org\apache\commons\codec\binary\Base64. java:335: error: cannot find symbol
int savedPos = context.pos;
symbol: variable pos
location: variable context of type Context
C:\...\src\org\apache\commons\codec\binary\Base64. java:336: error: cannot find symbol
switch (context.modulus) { // 0-2
symbol: variable modulus
location: variable context of type Context
C:\...\src\org\apache\commons\codec\binary\Base64. java:338: error: cannot find symbol
context.buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 2) & MASK_6BITS]; // top 6 bits
symbol: variable buffer
location: variable context of type Context
 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      08-29-2012
(unknown) wrote:
>> Lew wrote:
>> (unknown) wrote:

> Lew wrote:
>> Instead, either download or build the JAR,
>> ensuring thus that it contains *all* >> the project (Commons Codec in this
> > case). Since Apache Commons is, well, >> common, unless you're contributing
> > to the project download the JAR rather than > build it. > > Where can I get
> > either the pre-built jar or *all* of the project! http://lmgtfy.com/?

>
> q=Apache+Commons+Codec+downloads
>
> When I add the java package and your dot jar (from


I am not nor have ever been affiliated with the Apache Project, and I've made
no contributions to Commons Codec.

> http://commons.apache.org/codec/download_codec.cgi) to a project (as a library)
> and try to build it, I get error messages such as the below hard (if not impossible)
> to remove error messages. The error messages are from the new package.


Your use of the term "package" is inconsistent with Java usage.

What exactly do you mean?


> Compiling 46 source files to C:\...\build\classes
>
> C:\...\src\org\apache\commons\codec\binary\Base64. java:324: error: cannot find symbol


Why are you compiling the Commons Codec project?
This is what I told you *not* to do!

Stop compiling third-party source.

--
Lew
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot find symbol variable date Vojta Java 1 10-11-2006 11:25 AM
cannot find symbol fybar Java 6 04-25-2006 09:04 PM
Creating class gives "cannot find symbol" error luch Java 5 10-05-2005 04:13 PM
cannot find symbol DriverManager satyashil@exact-solutions.com Java 5 12-16-2004 07:55 PM
java:143: cannot find symbol Danny Java 1 05-26-2004 08:46 AM



Advertisments