c

RSA hex keys to PEM format

I have information about n,p,q where n=pq and p and q are large prime numbers to be used for the RSA algorithm. For example: n: C053094BFABF26D431CF33E028770DBB15F4AE76820B5150181F1BF42C5CF3AA7BDB459ACA77D610497F94FFA017BC07EF030E3D3450CAE7E706F352B7D7575CA6B89A5B3C953028E562F7F698C97FDD490EDF4788F073362C743B70AF2C61A17FA495E5801CC8EA1A...

Anyone know of a Daitch-Mokotoff implementation in Objective-C / C++ / C?

I want to compare user inputs with a string from a database. As I expect users to misspell all the time, I want to compare with a certain amount of slack. Apparently, Daitch-Mokotoff have developed a system that is rather precise, more so than Soundex. Does anyone know of an implementation of this system that will run on an iPhone (pre...

Read and copy file with EOF indicator in the middle

Hi, I used the code below to copy from one binary file to another, but the first file contains some EOF indicators (0xFF) as part of it, so the copy function actually copies the file until its first EOF indicator. For example: if my file is {0x01, 0x02, 0x03, 0xFF, 0x01, 0x02, 0xFF, 0xFF} then only {0x01, 0x02, 0x03} will be copied to ...

Where can I find a C99 front end with good error message for students

I'm teaching a course in which students get their first experience programming in C. We're using gcc on Linux and (for beginning students) the user experience is terrible. I'm looking for a C front end that will do one or more of the following: If it cannot find a .h file, announce the fact and shut up. Don't spray screenfuls of garb...

How can I make the system call write() print to the screen?

For my OS class I'm supposed to implement Linux's cat using only system calls (no printf) Reading this reference I found it being used to print to a file. I guess I should manipulate ofstream. In the example appears: ofstream outfile ("new.txt",ofstream::binary); How can I make it write to the screen? EDIT: I realized this write() is...

program to validate directory name.

I just wanna write a program which takes a directory name as argument Validate that it is in fact a directory Get a listing of all files in the directory and print it ...

Is there a standard Windows dialog for obtaining the proxy username and password?

Hi, I'm using WinHTTP to write an an app that needs access to the internet, and is potentially behind a proxy. Everything works (almost) out of the box is the user is on a domain, but if he or she isn't then I need a way to ask for credentials. Is there a standard way of doing that, or should I write my own dialog? Ideally I'd like som...

RSS/Atom C Parser

Do anybody know a good open source C RSS/Atom parser? ...

Operating system agnostic C library

Is there a C library available for operations such as file operations, getting system information and the like which is generic, which can be used when compiled in different platforms and which behaves in a similar way? Edit: Something like Java or .NET platform abstracting the hardware. ...

Using system calls to implement the unix cat command.

For my OS class I have the assignment of implementing Unix's cat command with system calls (no scanf or printf). Here's what I got so far: (Edited thanks to responses) #include <sys/types.h> #include <unistd.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> main(void) { int fd1; ...

4-variable mapping into an array

I need to choose an aray item based on the values of 4 variables, as shown below, in C. 0 | 1 | 0 | -1 | array[1][0] -1 | 0 | 1 | 0 | array[1][1] 0 | -1 | 0 | 1 | array[1][2] 1 | 0 | -1 | 0 | array[1][3] 1 | 0 | 0 | -1 | array[2][0] 1 | 0 | 0 | 1 | array[2][1] -1 | 0 | 0 | 1 | array[2][2] -1 | 0 |...

GCC forward declarations and __may__alias

I'm trying to forward declare a class with the _may_alias attribute, but GCC gives an error when I attempt to do so: struct __attribute__((__may_alias__)) MyType; MyType* foo(); typedef struct __attribute__((__may_alias__)) MyType { ... } MyType; MyType* foo() {} Gives the error: testc.c:4: error: redefinition of typedef ‘A’ ...

How would I make a pointer to an array of data work in C?

I have four arrays of data (3072 bytes each.) I want to point to one of these arrays, so if a function were passed a pointer to these arrays, it could manipulate them, and the pointers could be s So initially I thought of pointers-to-pointers: uint16_t *buffer0_level[BUFF_WORDS] FAR; uint16_t *buffer0_mask[BUFF_WORDS] FAR; uint16_t *bu...

Image Dithering: How would I calculate quantization error and nearest colour to implement in a Floyd-Steinburg algorithm?

I intend to display (4, 8 or 16 bit per channel - no alpha) images on a 1 bit display in an embedded system. Images are stored in RGB tuples. My intention is to use Floyd-Steinburg, as it looks reasonably good, is more than quick enough and concise in code. In reference to the WikiPedia article, I have two questions. What would the b...

Is there any setfill() alternative for C?

In C++: int main() { cout << setfill('#') << setw(10) << 5 << endl; return 0; } Outputs: #########5 Is there any setfill() alternative for C? Or how to do this in C without manually creating the string? Thanks in advance. ...

Is there any C compiler to show you linked program in asm?

I am searching for a compiler or better IDE for C which could generate completely linked program, including functions from CRT, in assembler form. Is there any? I tried Visual C Express 2008. It has a disassembler, but its somewhat strange. I mean for some reason it shows many "strange" lines of code, such as mov a,#3 in about 100 lines....

Count number of parameters in C variable argument method call

When using va_start(), va_arg() and va_end() to read parameters passed to a method, is there a way to count how many arguments there are? According to the man page if you call va_arg() too many times you get "random errors": If there is no next argument, or if type is not compatible with the type of the actual next argument (as ...

How can I limit memory acquired with `malloc()` without also limiting stack?

I'm trying to keep student code from running wild with allocations and dragging my test machine to a halt. I've tried setrlimit(RLIMIT_DATA, r); where r is a struct holding the limits. But unfortunately although this limit stops brk and sbrk from allocating, the C library just fails over to mmap and keeps right on allocating. I've ...

What exactly happens when you dereference a static variable in C?

So lets say I have this code int my_static_int = 4; func(&my_static_int); I passed the function a pointer to my_static_int, obviously. But what happens when the code is compiled? Avenue I've considered: 1) When you declare a non-pointer variable, C automatically creates its pointer and does something internally like typedefs my_stati...

A question on pointers

Take this piece of code: int a; int *pointer = &a; int **b = &(&(*pointer)); Would the above set b to the address of pointer or not? The reason I ask is because *pointer gives the value of a, and the reference of that is the address of a. Is this treated as just the address of a, or is it also treated as pointer. Does this make sen...