50 Reputation

7 years, 259 days

Random flipped bit ...

Maple

May I know any command can help to random selected a position in a group of bit number then flip that number but with condition after convert to bytes the number cannot be more than 7?

For example,

I have integer 3, i convert to binary become 0000011

then i need a command to random select a position to flip and only one bit can be flipped.

After that the group of flipped number will convert back to decimal, but total value cannot more than 7? any command can solve?  Thank you.

How to eliminate the commas in a list?...

Maple

For example:

[2,4,9,15,20]

I want the output be 2491520.

Any command can solve the problem? Thank you.

Ascii key value...

Maple

Hello everyone, Im now doing my fyp project in cryptography. I need to encrypt a message by using genetic operator, mutation and crossover and decrypt it after that.

For example:

message:=elgamal;

m:=convert(message,bytes);

with(Bits):

for i from 1 to l do
bit[i]:=Split(M[i]);

end do;

After that I will use genetic operator to change some bit for each character.

The output I might get will be something like this [1,1,1,1,1,1,1] , after that I need to convert it back to Ascii key value by join function, but sometime it might exceed 127 which out of the range of Ascii key value. Any command can solve this problem or any method can be used which will not affect the original message? Thank you.

How to convert a word to binary number?...

Maple

Hello, anyone know how to convert a word to 8 bits binary number ?

For example:

Here is my code:

message:=Hello
m:=convert(message,bytes);

>m:=[104,101,108,108,111]

with(Bits):

for i from 1 to 5 do:
mb[i]:=Split(m[i]);

end do;

>mb[1]:=[0,0,0,1,0,1,1] mb[2]:=[1,0,1,0,0,1,1] mb[3]:=[0,0,1,1,0,1,1] mb[4]:=[0,0,1,1,0,1,1]

mb[5]:=[1,1,1,1,0,1,1]

Anycommand can add additional one column when split the words into binary to form 8 bit in each row? Any help will be highly appreciated. Thank you.

User interface ...

Maple

Hi, all. I need to built a user interface for my program. First, I create two label and two text area for both the value of x and y. After that I assign a button to random generate the value for x and y within the range with x <y. I write the code below into click action of the button.

use DocumentTools in

Do(%x=RandomTools[Generate](integer(range=1..7);

Do(%y=RandomTools[Generate](integer(range=1..7);

while %x>= %y do

Do(%x=RandomTools[Generate](integer(range=1..7);

Do(%y=RandomTools[Generate](integer(range=1..7);

end do;

end use;

This code can generate two random number and insert inside the boxes created. When the button is clicked, two random number generated but the error dialog box shown on the screen with message : Error in component button with caption "generate" cannot determine if this expression is true or false: %y=%x. What I want is only the true value of x<y will be inserted to the text boxes.

Any suggestion? Any help will be highly appreciated. Thank you.

 1 2 3 Page 2 of 3
﻿