小编Ste*_*ios的帖子

对"crypt"的未定义引用

我正在使用下面的代码,我在网络的某个地方找到了,当我尝试构建它时,我收到了一个错误.编译还可以.

这是错误:

/tmp/ccCnp11F.o: In function `main':

crypt.c:(.text+0xf1): undefined reference to `crypt'

collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

这是代码:

#include <stdio.h>
 #include <time.h>
 #include <unistd.h>
 #include <crypt.h>

 int main()
 {
   unsigned long seed[2];
   char salt[] = "$1$........";
   const char *const seedchars =
     "./0123456789ABCDEFGHIJKLMNOPQRST"
     "UVWXYZabcdefghijklmnopqrstuvwxyz";
   char *password;
   int i;

   /* Generate a (not very) random seed.
      You should do it better than this... */
   seed[0] = time(NULL);
   seed[1] = getpid() ^ (seed[0] >> 14 & 0x30000);

   /* Turn it into printable characters …
Run Code Online (Sandbox Code Playgroud)

c crypt cryptography linker-errors

8
推荐指数
1
解决办法
2万
查看次数

Android Aes加密垫块已损坏

我正在使用下面的方法,如果我输入了正确的键,一切都会正常。但是,如果我输入了错误的密钥,我将收到BadPaddingException:pad块损坏……我做错了吗?

public  void initKey(String passwd, byte[] salt) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException{

    byte[] localsalt = salt; 
   PBEKeySpec password = new PBEKeySpec(passwd.toCharArray(),localsalt, 1024,128);//, localsalt, 1000, 128);  //128bit enc aes
   SecretKeyFactory factory = SecretKeyFactory.getInstance("PBEWithMD5And128BitAES-CBC-OpenSSL","BC");  
   PBEKey key = (PBEKey) factory.generateSecret(password);  
   encKey = new SecretKeySpec(key.getEncoded(), "AES");
}


public   String txt2enc(String etxt) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException {

       final Cipher cipher = Cipher.getInstance("AES");//AES       
       cipher.init(Cipher.ENCRYPT_MODE, encKey);      

       byte[] encrypted = cipher.doFinal((etxt).getBytes("UTF-8"));
       return Base64.encodeToString(encrypted, 0);
}

//decryption
public  String txt2dec(String dtxt) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, …
Run Code Online (Sandbox Code Playgroud)

encryption android aes

3
推荐指数
1
解决办法
6720
查看次数

Java Swing显示问题

我在SWING写了一个gui程序,但我有一个奇怪的问题.我有一个框架,一个面板,一个菜单和组件.我将所有组件放在面板中,然后将此菜单添加到框架中.

当我运行该程序时,它只显示一个带有菜单的窗口,但如果我最大化窗口或只是更改窗口的一小部分,当它运行所有组件出现!

这是一个错误还是什么?

java swing

1
推荐指数
1
解决办法
626
查看次数

标签 统计

aes ×1

android ×1

c ×1

crypt ×1

cryptography ×1

encryption ×1

java ×1

linker-errors ×1

swing ×1