Encript Timestamp with blowfish


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Encript Timestamp with blowfish
# 1  
Encript Timestamp with blowfish

Good afternoon to you all

I need help

I need a script that will allow to encrypt the system´s timestamp;

I have to use a pre-shared key to cipher the timestamp, so basically I need:

1st) cipher with a pre-shared key
2nd) encrypt the timestamp
3rd) encode on a base64

the output should be something like:

g_6iIMPST6ZXcc9Yk3jYtA==

I would really apreciate your help
# 2  
See man crypt for 1 & 2.
The 'net is full of base 64 encode/decode tools. I wrote my own C decoder:

Code:
$ cat mysrc/base64dec.c

#include <stdio.h>
#include <stdlib.h>
#include <strings.h>

static int i, o ;
static int ostate = 0 ;

static void p_putchar( int c ){
//fprintf(stderr,"p_putchar(%d=%c)\n",c,c);
  if ( EOF == putchar( c )){
    if ( ferror( stdout )){
      perror( "base64dec: stdout" );
      exit( 1 );
     }

    exit( 0 );
   }
 }

static void newbits( int b ){
//fprintf(stderr,"newbits(%d), ostate %d, o %d, i %d=%c\n",b,ostate,o,i,i);
  switch ( ostate ){
   case 0:
    o = b ;
    ostate = 6 ;
    return ;
   case 6:
    p_putchar( ( o << 2 ) | ( b >> 4 ) );
    o = b & 15 ;
    ostate = 4 ;
    return ;
   case 4:
    p_putchar( ( o << 4 ) | ( b >> 2 ));
    o = b & 3 ;
    ostate = 2 ;
    return ;
   default:
    p_putchar( ( o << 6 ) | b );
    ostate = 0 ;
    return ;
   }
 }

int main( int argc, char **argv ){

  int v = 0 ;

  if ( argc > 1
    && !strcmp( argv[1], "-v" )){
      v = 1 ;
   }

  while ( EOF != ( i = getchar())){
    if ( i > 'z' ){
      continue ;
     }

    if ( i < '+' ){
      continue ;
     }

    if ( i > 'Z' ){
      if ( i >= 'a' ){
        newbits( i - 'a' + 26 );
       }
      continue ;
     }

    if ( i >= 'A' ){
      newbits( i - 'A' );
      continue ;
     }   

    if ( i > '9' ){
      continue ;
     }   

    if ( i >= '0' ){
      newbits( i - '0' + 52 );
      continue ;
     }   

    if ( i == '/' ){
      newbits( 63 );
      continue ;
     }   

    if ( i == '+' ){
      newbits( 62 );
     }   
   } /* end while getchar */

  if ( ferror( stdin )){
    perror( "base64dec: stdin" );
    exit( 1 );
   }

  if ( ostate && v ){
    fprintf( stderr,
"\nbase64dec: Warning: %d bits =%d left at EOF.\n",
      ostate, o );
    exit( 2 );
   }

  exit( 0 );
 }

This User Gave Thanks to DGPickett For This Post:
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #367
Difficulty: Medium
The Single UNIX Specification specifies vi, so every conforming UNIX system must have it.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep lines between last hour timestamp and current timestamp

So basically I have a log file and each line in this log file starts with a timestamp: MON DD HH:MM:SS SEP 15 07:30:01 I need to grep all the lines between last hour timestamp and current timestamp. Then these lines will be moved to a tmp file from which I will grep for particular strings. ... (1 Reply)
Discussion started by: nms
1 Replies

2. Shell Programming and Scripting

AIX : Need to convert UNIX Timestamp to normal timestamp

Hello , I am working on AIX. I have to convert Unix timestamp to normal timestamp. Below is the file. The Unix timestamp will always be preceded by EFFECTIVE_TIME as first field as shown and there could be multiple EFFECTIVE_TIME in the file : 3.txt Contents of... (6 Replies)
Discussion started by: rahul2662
6 Replies

3. Shell Programming and Scripting

To check timestamp in logfile and display lines upto 3 hours before current timestamp

Hi Friends, I have the following logfile. Currently time in india is 07/31/2014 12:33:34 and i have the following content in logfile. I want to display only those entries which contain string 'Exception' within last 3 hours. In this case, it would be the last line only I can get the... (12 Replies)
Discussion started by: srkmish
12 Replies

4. Homework & Coursework Questions

[SOLVED] blowfish algorithm: encrypting the p-array.

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I am trying to encrypt the p-array. The first element will print correctly once returned from my encrypt... (2 Replies)
Discussion started by: robin_simple
2 Replies

5. Shell Programming and Scripting

Identifying files with a timestamp greater than a given timestamp

I need to be able to identify files with file timestamps greater than a given timestamp. I am using the following solution, although it appears to compare files at the "seconds" granularity and I need it at the milliseconds. When I tested my solution, it missed files that had timestamps... (3 Replies)
Discussion started by: nkm0brm
3 Replies

6. UNIX for Dummies Questions & Answers

How to compare a file by its timestamp and store in a different location whenever timestamp changes?

Hi All, I am new to unix programming. I am trying for a requirement and the requirement goes like this..... I have a test folder. Which tracks log files. After certain time, the log file is getting overwritten by another file (randomly as the time interval is not periodic). I need to preserve... (2 Replies)
Discussion started by: mailsara
2 Replies

7. Shell Programming and Scripting

Getting a relative timestamp from timestamp stored in a file

Hi, I've a file in the following format 1999-APR-8 17:31:06 1500 3 45 1999-APR-8 17:31:15 1500 3 45 1999-APR-8 17:31:25 1500 3 45 1999-APR-8 17:31:30 1500 3 45 1999-APR-8 17:31:55 1500 3 45 1999-APR-8 17:32:06 1500 3 ... (1 Reply)
Discussion started by: vaibhavkorde
1 Replies

8. Shell Programming and Scripting

how to encript a shell

I have a unix shell, there is a way to encript the whole shell, and be able to run the encripted shell, so I can give my client the encripted shell, and he can't see the code I wrote? (6 Replies)
Discussion started by: pedro_lezaeta
6 Replies

9. Shell Programming and Scripting

how to encript password in .netrc file

hi, I am using .netrc file WITH OUT encripting the password Code in .netrc file: ------------------- machine $SYSTEM NAME login FTFOA001 password 1Q2W3E4R how to encript password in .netrc file.(i should not use "1Q2W3E4R" as password). after encripting i should able to connect with... (1 Reply)
Discussion started by: getgopu25
1 Replies

10. UNIX for Advanced & Expert Users

samba questions (password conversion to blowfish and is it wise to sync the useraccou

i stumbled upon something that gave some nice instructions on how to convert FreeBSD passwords from md5 to blowfish. it was simple and straight forward and it worked. i'm running samba on the machine. now i know the tutorial i was following had something where a user's samba and machine... (1 Reply)
Discussion started by: xyyz
1 Replies

Featured Tech Videos