I have a Java app (not written by me) which uses javax.crypto to encrypt and decrypt file.
public static final String PROVIDER = "BC";
public static final int SALT_LENGTH = 32;
...
Type: Posts; User: polslinux
I have a Java app (not written by me) which uses javax.crypto to encrypt and decrypt file.
public static final String PROVIDER = "BC";
public static final int SALT_LENGTH = 32;
...
Thanks Andi :-) i will solve this after the padding problem ;-)
@Salem: so the correct flow for the encryption program could be:
1) read the file size, divide it by 16 and get the number of total...
Encryption program:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gcrypt.h>
#define GCRYPT_VERSION "1.5.0"
Also remember to alwasy check the return value of a function.
In your case you have to check the ret. val. of fgets and strstr :)
A little tip: use always:
int main(void)neither
main()nor
int main() :)
I've found the bug :) The problem was that i had a
recv(f_sockd, buf, sizeof(buf), 0);
where buf is
char buf[256] but the real received buf was only 5 chars!
So i have changed the above...
Hello :)
1) i've deleted only the checks of the open and stat calls (if ... < 0 then error):)
2) the other 3d is for another problem :)
3) thanks, i was desperate so i've tried all without know...
the problem is into my program because i've tried to code a small socket program that exchange an int (send(sock, &val, sizeof(val), 0)) and it works perfectly -.-''
The program works perfectly the only problem is when i have to send the file size because it doesn't works :(
yes, i've used it!
I know but it is only a personal project to understand and study C (and network programming) :)
However I have built them with "make"!
And no, "asdk" isn't in any file i've used xD
./ftpserver 2000
./ftpclient localhost 2000
no! i'm doing some test and only me are connected to my network :)
I'm running client and server on the same machine with Ubuntu 12.04-amd64 (errors checking have been deleted).
Server send:
uint32_t fsize;
struct stat fileStat;
fd = open(filename,...
This part of code is for the client. It need to receive first the file size and then the size:
void do_retr_cmd(int f_sockd){
int fd;
ssize_t nread = 0;
uint32_t fsize, fsize_tmp,...
i've solved :D
the problem was that i have to put offset_list = 0; BEFORE every call to sendfile :)
With this it doesn't works :(
send_again:
rc_list = sendfile(newsockd, fpl, &offset_list, fileStat.st_size);
if(rc_list == -1){
perror("Invio file list non riuscito");
...
This is the part of the ftp cmd "LIST" :
if(recv(newsockd, buffer, 5, 0) < 0){
perror("Errore nella ricezione comando LIST");
onexit(newsockd, sockd, 0, 2);
}
other =...
Gooooood it woooooooooorks :D :D :D :D :D :D
you're a fukin genius :D :D
again fsize! So i have to change
nread = read(sockd, filebuffer, fsize)
to
nread = read(sockd, filebuffer, fsize_tmp)
where
fsize_tmp = fsize
Also with fsize instead of sizeof(filebuffer) i got the messages problem :(
This is a snippet of my client code:
while(((uint32_t)total_bytes_read != fsize) && ((nread = read(sockd, filebuffer, sizeof(filebuffer))) > 0)){
if(write(fd, filebuffer, nread) < 0){
...
I have a doubt if to use `goto` or `pointer to a function` into my code. Here a pseuco C code using goto:
/* code that read the answer */
switch-case:
switch(answer)
case LIST:
goto...
In fact this is a (very small) ftp client and server. Only USER PASS LIST CD CWD RETR have been developed :)
And also thanks to all, i will study struct better once i've finished this project!! :)
What you have write it is too hard for me xD i'm "developing" in C since May 2012 :)
i have not completely understand "how and when to use struct" so i don't use them (for now) ;)